I tried two ways to get timevisited on an ID from one of my tables (assuming the table is Jokes)...
basically i want my php page to update timevisited whenever the id is accessed like Jokes.php?ID=1...
1)
$sql = "UPDATE Jokes SET TimesViewed=TimesViewed+1 ".
"WHERE ID=$ID";
// i got this from kevin yank's article in sitepoint.com
// btw thank you kevin, your article helped me out ALOT
2)
$updates = mysql_query("SELECT TimesViewed From Jokes WHERE ID=$ID");
$update = mysql_fetch_array($updates);
$counts = $update["TimesViewed"];
echo("$counts"); // this can be ignored
$counts = $counts + 1;
echo("$counts"); // this can be ignored
$sql = "UPDATE Deals SET TimesViewed=$counts ".
"WHERE ID=$ID";
for both i loaded up the db before...
as for the second example, the first echo with show (for example) 1, and the second on will show 2... like how it is suppose to... but the new counts somehow isn't updated...
This is extremely fustrating... i been working on this for... hmm... four hours, trying different methods, but somehow all efforts been unsuccessful.
the sql query command works under sql command prompt, but doesn't under php.
am i missing something...
Thank You (beforehand)...
Labmice
ps. anyone can try this code, just create a db table with ID=1 and TimesViewed=(zero or 1). remember to set $ID=1 in the beginning of the script...