asad_black Posted August 24, 2009 Share Posted August 24, 2009 this is my page: http://www.tutioninn.com/id_videos.php?v_id=13 now in this page i want to show that how many times people visit this video..! also this value save in the database...! like: http://www.jugnoo.tv/idpage.php?id=29 i have no idea about it..! kindly solve my problem soon:( this is my code $result = mysql_query("SELECT * FROM my_vid WHERE v_id =$vid_id"); echo "<table border='0' width='50%' align='center'> <tr valign=top> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr valign=top>"; // echo "<td>" . $row['v_name'] . "</td>"; echo "<br>"; echo "<td align='center' style='font:Arial, Helvetica, sans-serif; font-size:14px; font-weight:bold; text-transform:uppercase;'>" . $row['v_name'] . "</td>"; echo "</tr>"; echo "<tr valign=top>"; echo "<td align='center' style='font:Arial, Helvetica, sans-serif; font-size:14px; color:#006699'>" . $row['v_des'] . "</td>"; echo "</tr>"; echo "<tr valign=top>"; echo "<td>" . $row['v_emb'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Quote Link to comment https://forums.phpfreaks.com/topic/171671-i-want-to-display-that-how-many-people-visit-video/ Share on other sites More sharing options...
ignace Posted August 24, 2009 Share Posted August 24, 2009 You should have a field something similar like below in your table: CREATE TABLE videos ( videos_times_viewed INTEGER, ); When a user views a video update the table: UPDATE videos SET videos_times_viewed = videos_times_viewed + 1 WHERE videos_id = $id Quote Link to comment https://forums.phpfreaks.com/topic/171671-i-want-to-display-that-how-many-people-visit-video/#findComment-905244 Share on other sites More sharing options...
asad_black Posted August 24, 2009 Author Share Posted August 24, 2009 thankx for the reply...! yeah i have a field in the database with the name of v_hits if you modified my code or show to do this implement then i will be very thankful of you..! Quote Link to comment https://forums.phpfreaks.com/topic/171671-i-want-to-display-that-how-many-people-visit-video/#findComment-905245 Share on other sites More sharing options...
ignace Posted August 25, 2009 Share Posted August 25, 2009 if (!isset($_SESSION['video_viewed']) ^ $_SESSION['video_viewed'] !== $vid_id) { $_SESSION['video_viewed'] = $vid_id; mysql_query("UPDATE my_vid SET v_hits = v_hits + 1 WHERE v_id = $vid_id"); } $result = mysql_query("SELECT * FROM my_vid WHERE v_id =$vid_id"); echo "<table border='0' width='50%' align='center'> <tr valign=top> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr valign=top>"; // echo "<td>" . $row['v_name'] . "</td>"; echo "<br>"; echo "<td align='center' style='font:Arial, Helvetica, sans-serif; font-size:14px; font-weight:bold; text-transform:uppercase;'>" . $row['v_name'] . "</td>"; echo "</tr>"; echo "<tr valign=top>"; echo "<td align='center' style='font:Arial, Helvetica, sans-serif; font-size:14px; color:#006699'>" . $row['v_des'] . "</td>"; echo "</tr>"; echo "<tr valign=top>"; echo "<td>" . $row['v_emb'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); Quote Link to comment https://forums.phpfreaks.com/topic/171671-i-want-to-display-that-how-many-people-visit-video/#findComment-905642 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.