IBEX Posted November 26, 2008 Report Share Posted November 26, 2008 $sql = "SELECT counter FROM video WHERE video_id = {$_GET['video_id']}"; $result = mysql_query($sql) or die (mysql_error()); $rows = mysql_fetch_array($result); $page_views = $rows['counter']; if (empty($page_views)) { $page_views = "1"; mysql_query("INSERT INTO video (counter)VALUES('1') WHERE video_id = {$_GET['video_id']}"); } $page_views++; $sql = "UPDATE video SET counter = $page_views WHERE video_id = {$_GET['video_id']}"; $result = mysql_query($sql) or die (mysql_error()); Kas sheit ir nepareizi?.. man liekas ieksha nevis 1, bet 2.. Link to comment Share on other sites More sharing options...
andrisp Posted November 26, 2008 Report Share Posted November 26, 2008 Viss taču ir pareizi - tu $page_views (kam vērtība ir 1) palielini par vienu, rezultātā sanāk 2. Link to comment Share on other sites More sharing options...
IBEX Posted November 27, 2008 Author Report Share Posted November 27, 2008 ka panakt lai rezultata butu 1?.. Link to comment Share on other sites More sharing options...
andrisp Posted November 27, 2008 Report Share Posted November 27, 2008 Pieliec else. Tb, ja $page_views tomēr nav tukšs, tad updeito. Link to comment Share on other sites More sharing options...
codez Posted November 27, 2008 Report Share Posted November 27, 2008 vispār jau to var uzrakstīt vienā kverijā: INSERT INTO video (video_id,counter) VALUES (444,1) ON DUPLICATE KEY UPDATE counter=counter+1; Link to comment Share on other sites More sharing options...
Recommended Posts