Array's,Mysql, and the rand help please!
Posted: Sat May 31, 2003 1:54 pm
Hi...
I want to select every id in a table called bb_vote where active = yes, then put the results into an array, and then choose an ID number at random.
I have made this script so far but unfortunaly it only displays ID=1 and no other ID.
I spelled the variables Aray as I thought calling it Array may be causing a conflict.
Could someone please help me... and sorry about my punctuation and spelling! lol
I want to select every id in a table called bb_vote where active = yes, then put the results into an array, and then choose an ID number at random.
I have made this script so far but unfortunaly it only displays ID=1 and no other ID.
Code: Select all
$sql="select id from bb_vote where active=('y')";
$result=mysql_query($sql)
or die ("cant do check!");
$aray= mysql_fetch_array($result);
$num = mysql_num_rows($result);
$random=array_rand($aray,1);
$sql2="select id,loginName,info,pic from bb_vote where id=($arayї$random])";
$result2=mysql_query($sql2)
or die ("cant do check!");
$all = mysql_fetch_array($result2);
$num2 = mysql_num_rows($result2);
extract ($all);Could someone please help me... and sorry about my punctuation and spelling! lol