Posted by J.O. Aho on 04/06/06 17:41
Duderino82 wrote:
> I wanted to ad a counter to records. So when the user views the details
> of the record I punch in this php line:
>
> $qry = mysql_query("SELECT * FROM $table WHERE code='$code'",$db);
> $row=mysql_fetch_array($qry);
> $row[view]++;
> $str="UPDATE $table SET view='$row[view]' WHERE code=$code";
> mysql_query($str,$db);
> when I check $row[view] after the increment it actually cointains
> $row[view]++. Even the SQL string is correct. Lets say $row[view] was
> 23 then $str is:
>
> UPDATE $table SET view='24' WHERE code=$code
Try with
$str="UPDATE $table SET view=view+1 WHERE code=$code";
//Aho
Navigation:
[Reply to this message]
|