Dude you can use the same code form the while function on. Like so..
<?
//*********************Start code for section 1*********************
if($section == "1"){
$random_number = rand(1,$highest_id_number_in_this_table);
$dg = mysql_query(SELECT * FROM ugn_confession1 WHERE id = '$random_number');
//*********************Start code for section 3*********************
}else if($section == "3"){
$random_number = rand(1,$highest_id_number_in_this_table);
$dg = mysql_query(SELECT * FROM ugn_confession2 WHERE id = '$random_number');
}
//after all the if statements you just do one while statement
While($dg2 = mysql_fetch_array($dg)){
echo "".$dg2['type']."
";
echo "".$dg2['date']."
";
echo "".$dg2['id']."
";
echo "".$dg2['name']."
";
echo "".$dg2['confession']."
";
}
See the only thing that is different is you have to handle the rand(); function and mysql_query in the if, else statements. The rest is the same because the variable $dg is passed to while just the same. The reason is only one $dg = mysql_query(); function will be processed. Make sense?
Also your table need to be constructed identicaly for this to work of course.
Now you could do it in one table IF.....
Section 1 is id numbers 1 - 500
Section 2 is id numbers 501 - 1000
Section 3 is id numbers 1001 - 1500
and so on
This would be difficult to update dynamicaly though. But if you did this this way the first script I posted today would work. But the id's have to be sequential to do the random functions I coded. Of course, maybe you could put it into an array... hmmmmmm
**note This may cause it to be slower for some reason. I have used arrays a bit lately and found they seem to slow things down a bit. But that is on my 2 servers
Solaris OS running apache and Redhat9 Running apache
$dg = ("SELECT * FROM you_table WHERE id = '$section'");
$count = "0"
$number_rows = mysql_num_rows($dg);
WHILE($dg mysql_fetch_array($dg)){
$ugn_array = $dg2;
}
$random_num = (0, $number_rows);
echo "".$ugn_array['$random_num']['type']."
";
and so on...
that should work for you....