Forum Moderators: coopster

Message Too Old, No Replies

Loading randomly generated id page

         

dkin

5:08 pm on Dec 17, 2004 (gmt 0)

10+ Year Member



I am creating a rating site, say this site is for mustangs, I want to make it so when a radio button is clicked it submits to the database and randomly picks another page to display. How exactly would I do this?

mcibor

7:48 pm on Dec 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can use rand function. eg

$min = 0;
$max = 10;
$no = rand($min, $max);

then from SQL take page address that has $no id:
SELECT page FROM addresses WHERE id > $no ORDER BY id;

this way if there are some missing it will give you first that is there. You can try estimating the $max value by
SELECT MAX(id);.

then
include($page);

Have fun!