I'm trying to generate random numbers that I use to present random info.
here's my code
//query for box 1
srand(time());
$random = (rand()%11);
srand(time());
$random2 = (rand()%11);
if ($random2 === $random){
srand(time());
$random2 = (rand()%11);}
else{
printf ($random);
printf ($random2);
$query1 = ('select * from mb_consultants where consultant_id = "$random"');
$result1 = mysql_query($query1);
$db_result1 = mysql_fetch_array($result1);
// query for box 2
$query2 = ('select * from mb_consultants where consultant_id = "$random2"');
$result2 = mysql_query($query2);
$db_result2 = mysql_fetch_array($result2);
}
then I use the following code to grab info from the database
<?php { echo $db_result2["consultant_intro_blurb"]; }?>
but it doesn't work.
Yet if I don't use random generated numbers and I input a number from 1 to 11 for example:
$query1 = ('select * from mb_consultants where consultant_id = "1"');
it works
why doesn't my random code work?
thanks