- Joined
- Jul 22, 2002
- Messages
- 872
- Reaction score
- 0
i'm using the php function rand() to determine a random record to display by doing the following (pseudo-code)
$max = select max(id_field) from table
$id = rand(1,$max)
$result = select * from table where id_field = $id
this works great except i have removed some rows from the table so there are gaps in the id_field so when it hits an $id that no longer exists mysql_result($result,0,'column_name') falls over with cannot jump to row 0 in table (because $result is empty)
any ideas on a way around this.
Ciq
$max = select max(id_field) from table
$id = rand(1,$max)
$result = select * from table where id_field = $id
this works great except i have removed some rows from the table so there are gaps in the id_field so when it hits an $id that no longer exists mysql_result($result,0,'column_name') falls over with cannot jump to row 0 in table (because $result is empty)
any ideas on a way around this.
Ciq