if you want to have the columns split in an even order you will need to count the returned results first:
$countRecords = "SELECT COUNT(id) as totalRecords FROM Table WHERE blahblah=$blahblah";
user the same query you run to print out the info except with count(id) as totalRecords instead - if you are joining the tables make sure you group by the table with the main records
$result = mysql_query($countRecords);
$resultsPerColumn = mysql_result($result, 0);
you could also use, instead of COUNT(id) just use id and use the mysql_num_rows function instead.
Ok once you get the result of the count divide
$resultsPerColumn = CEIL($totalResults/2);
this will give you the amounts on each side.
now initialize a variable at 0 & 2 other variables like
$countRecords = 0;
$firstColumn = '
'
$secondColumn = ''
From here run your query like you did
while( $row=mysql_fetch_array($sql)) {
if($countRecords < $resultsPerColumn ){
$firstColumn .= '' . $row['id'] . ' | ' . $row['user'] . ' | ';
$countRecords++;
}
else{
$secondColumn .= '' . $row['id'] . ' | ' . $row['user'] . ' | ';
}
}
$firstColumn .= "
";
$secondColun .= "
";
?>
=$firstColumn?>
|
=$secondColumn?>
|
Now is it worth it to do this if you can avoid it? Probably not, but if you need to you can do it this way.
This is just one way I'm sure, and im sure its not the most efficient but its an answer for you.