Hi...
The code I'm working with is below :
do {
$sql = "SELECT * FROM table WHERE table_status = '1'";
$result = @mysql_query($sql, $connect) or die(mysql_error());
$dnum = mysql_num_rows($result);
$drnd = rand(1, $dnum);
$sql2 = "SELECT * FROM table WHERE table_id = '$drnd'";
$result2 = @mysql_query($sql2, $connect) or die(mysql_error());
while ($row = mysql_fetch_array($result2)) {
$t_id = $row['table_id'];
$t_name = $row['table_name'];
$t_email = $row['table_email'];
$t_age = $row['table_age'];
}
$age = "25";
} while ($age < "$t_age");
echo "Client Name : $t_name";
echo "Client Email : $t_email";
What I am trying to accomplish is this:
I'm trying to generate a random selection within the query using the loop. What I need to have happen is the first query runs and gets all the records with a TABLE_STATUS of 1... and then I need THAT result ran through to find a single record that has TABLE_AGE less than the $age variable. I need to have the end result be random every time the query / loop is run.
I've tried a couple other ideas with no success... how can I accomplish this? I'm fairly new to loops... I think than an array may work, but I'm not very familiar with working with arrays either unfortunately.