TAGS :Viewed: 6 - Published at: a few seconds ago

[ How can we see how many times a particular video watch? (in php) ]

I have a database from which i retrieve a path of video in server and 'echo' this path in src of video element of html.I did all this thing in loop.Like this:

<html>
<body>
<?php
$query=mysql_query("SELECT * FROM videos");

while($row=mysql_fetch_array($query)){?>

<video controls width="320" height="264">

<source src="<?php echo $row['videoPath']; ?>" type='video/mp4' />

</video>
<?php
}
?>
</body>
</html>

Q:Now i also want to see how many times a particular video is watched? How can i do this?

Answer 1


have you considered putting a field in your table to count how many times a video was ordered i believe that is the best way to accomplish what you want

Answer 2


Moneer Kamal is right, Jusst add an extra field in your DB that increments. You shouldn't use mysql as it is a security risk, Look into mysqli or PHP PDO for connecting to your DB.