I'm trying to make a random quote script using php.
i have a mysql table 'quotes' with 3 columns, ID, quotes, author.
what i want to do is create a randomize number from 1 to the number of quotes available in the table base on the ID. Then display the quote base on that.
Any help would be greatly appreciated!
Well the only problem is that if you are using an auto-incrementing field for your ID there may be a chance that you could select an ID that has been deleted, but anyways here is a script that will suit your needs. I also use PHPLIB for my db stuff, so if this doesn't make sense let me know and I will put into regular php.
$db = new DB;
$db->query("SELECT count(ID) as count from listings");
$count = $db->f(count);
$rand = rand (0,($count));
$db->query("SELECT * FROM listings WHERE ID = '$rand'");