Jump to content

I want to display that how many people visit video...!


asad_black

Recommended Posts

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);
?>


 

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

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);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.