It's quite straight forward, and this should do it with your current code.
$aNames = array();
$j=0;
while ($j <$rows)
{
$aNames[]=($SQL_Result[name][$j]);
$J++;
}
shuffle($aNames);
// BLAA BLAA HTML OPEN TABLE
$j=0;
while ($j <$rows)
{
echo $aNames[$j];
$J++;
}
// BLAA BLAA HTML CLOSE TABLE
But here is how it is done in 'proper' code:
<?
error_reporting(E_ALL);
// Run the query
//
if (!$result = mysql_query("select * from restaurant where active_client='Y' "))
{
// If an error occured then print the error message
//
echo mysql_error();
}
else
{
// No errors occured, were there any results from the query?
//
if ($iNumRows = mysql_num_rows($result) == 0)
{
// Zero results from query, do nothing
}
else
{
// More than zero results, put them into an array
// First make an empty array:
$aRecords = array();
// Fetch a row, put it into the array, and keep doing that untill we can not fetch any more rows
while($aRow = mysql_fetch_array($result))
{
$aRecords[] = $aRow;
};
// Finished, now $aRecords contains all the rows that the query returned.
// Shuffle the array
shuffle($aRecords);
// And print the rows
for ($iT=0; $iT<$iNumRows; $it++)
{
echo $aRecords[$it]['field_name'];
};
};
};
?>