You will have to have a table or something in your MySQL database keeping track of all of your videos somehow obviously, and with a field saving the number of views...
So you would have to grab the value out of the MySQL database increase it by 1 and then save it back to the database.
ok i'll give a quick stab at an example...
Assuming you have a MySQL table named videos which has a field named views.
mysql table videos :
id | name | link | views
1 | Cool Vid | www.cool.com | 6
Code:
<?php
mysql_connect('localhost','root','r0x');
mysql_select_db('mycooldb');
$sql = mysql_query("SELECT * FROM `videos` WHERE `id`='1' ");
$getCount = mysql_fetch_row($sql);
$getCount = $getCount[3]; // fetch_row returns a numeric array
$getCount = $getCount++; // add one to the fetched number
mysql_query("UPDATE `videos` SET `views`='" . $getCount . "' WHERE `id`='1'");
// update the record with the new number of views
?>
There might be a syntax error or two in there, but thats the just of it.
__________________
stewart::howe
Web Developer & Programmer
Please login or register to view this content. Registration is FREE | Please login or register to view this content. Registration is FREE | CelerLabs.com
Last edited by stewart; 10-22-2007 at 01:02 AM..
|