Jump to content
php.lv forumi

update nenostrādā


ziedinjsh

Recommended Posts

Sveiki! Es īsti nesaprotu kapēc man nenostrādā update:


$id = (isset($_GET['id'])) ? $_GET['id'] : '';
$data = mysql_fetch_array(mysql_query("SELECT * FROM articles WHERE id='$id'")) or die(mysql_error());
$addviews = mysql_query("UPDATE articles SET views=views+1 WHERE id='$id'");
$title = $data['title'];
if(strlen($title) > 90) $title = substr($title, 0, 90).'...';

if(isset($_POST['like'])){
mysql_query("UPDATE articles SET like=like+1 WHERE id='$id'");
}

echo "
<div id='fullview' style='overflow:hidden;'>
<div class='title'>".$title."</div>
<div class='article'><div class='articlein'>".$data['article']."</div></div>
<div class=''>
<form method='post' action='".$_SERVER['PHP_SELF']."?s=read&id=".$id."'>
<input type='submit' name='like' value='patīk ".$data['like']."'>
</form>
</div>
</div>
";

 

Šis strādā

$addviews = mysql_query("UPDATE articles SET views=views+1 WHERE id='$id'");

bet otrais kas ir isset tas neapdeito! Kapēc tā? vai tad divi update nevar būt vienā lapā?

Link to comment
Share on other sites

Var jau gan laikam būt divi UPDEIT vienā lapā.

 

Bet... moš noprovē šitādu brīnumu

 

if(isset($_POST['like'])) {
$set="views=views+1, like=like+1";
} else {
$set="views=views+1";
}

$addviews = mysql_query("UPDATE articles SET ".$set." WHERE id='$id'");

Ko šis tad saka ?

Edited by nikidijs
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...