thme01 Posted October 29, 2011 Share Posted October 29, 2011 <?php $querySelect = mysql_query("SELECT * FROM `G4V_Videos` WHERE `counter`"); $row = mysql_fetch_assoc($querySelect); $counter = $row['counter']; if (empty($counter)) { $counter = 1; $insert = mysql_query ("INSERT INTO counter VALUES ('counter')"); $printid = (print $data['id']); $printlink = (print $data['link']); } $add = $counter+1; $insertNew = mysql_query("UPDATE G4V_Videos SET counter=('$add') WHERE id = ('$printid') AND link = ('$printlink')") or die (mysql_error()); echo "Video Views"; echo ":"; echo" "; echo"<br />"; echo "$counter"; ?> It shows the same amount of hits on everyvideo instead of just the one video with the id www.game4vids.com Link to comment https://forums.phpfreaks.com/topic/250050-help-with-update-mysql/ Share on other sites More sharing options...
Pikachu2000 Posted October 29, 2011 Share Posted October 29, 2011 If I'm correct about what you're trying to do here, assuming you have the default value of counter set to zero, and the field is an INT() data type, all you really need to do is execute one query to increment the counter. This won't likely be plug-n-play, but it should give you an idea of how to better handle it. UPDATE G4V_Videos SET counter = counter + 1 WHERE id = '$printid' Link to comment https://forums.phpfreaks.com/topic/250050-help-with-update-mysql/#findComment-1283264 Share on other sites More sharing options...
thme01 Posted October 29, 2011 Author Share Posted October 29, 2011 Thats what im trying to achive but it doesnt work. i have also tried your code and it doesnt work either :/ Link to comment https://forums.phpfreaks.com/topic/250050-help-with-update-mysql/#findComment-1283270 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.