This isn't a simple process. What you'd need to do is get your information into an array. Then count the number of items in the array (let's say we have 15 items). DIvide that number in two, and since we want it even, or more on the left than the right, we [man]ceil/man that number (so 15/2 = ceil(7.5) = 8). Now we know the start points of the left column, and the right. The left column would start at 0, the right column at 8 (or left column at 1, right column at 9). Now, you just itterate through your array and display $array[$left_col_num], $array[$left_col_num+8] (or $array[$right_col_num]).
It sounds confusing, but let me post an example of a function I made on here that switches between vertical and horizontal loops:
<?php
function vertHorizLoop($array, $cols=3, $horiz=true, $table=true)
{
$output = '';
// Define some defaults
$count = count($array);
if($table)
$output .= '
<table>
<tr>';
if(!$horiz)
{
$sect = array();
for($i=0; $i<$cols; $i++)
$sect[$i] = array();
$max = ceil($count/$cols);
$k=0;
for($i=0; $i<$count; $i++)
{
if($i%$max==0 && $i!=0)
$k++;
$sect[$k][] = $array[$i];
}
}
if($horiz)
{
for($i=0; $i<count($array); $i++)
{
if($i%$cols==0 && $i>0)
{
if($table)
$output .= '
</tr>
<tr>';
else
$output .= '<br>';
}
if($table)
$output .= '
<td>'.$array[$i].'</td>';
else
$output .= $array[$i].' ';
}
}
else
{
for($i=0; $i<$max; $i++)
{
foreach($sect as $key=>$arr)
{
if($table)
$output .= '
<td>'.$arr[$i].'</td>';
else
$output .= $arr[$i].' ';
}
if($table)
$output .= '
</tr>
<tr>';
else
$output .= '<br>';
}
}
if($table)
$output .= '
</tr>
</table>';
echo $output;
}
// Numbers for the 3x4 block:
$block = array('1','2','3','4','5','6','7','8','9','10','11','12');
// call our function:
echo '<h3>Horizontal [<i>Table</i>]:</h3>';
vertHorizLoop($block, 3, true); // Horizontal
echo '<hr>
<h3>Vertical [<i>Table</i>]:</h3>';
vertHorizLoop($block, 3, false); // Vertical
echo '<hr>
<h3>Horizontal [<i>HTML</i>]:</h3>';
vertHorizLoop($block, 3, true, false); // Horizontal
echo '<hr>
<h3>Vertical [<i>HTML</i>]:</h3>';
vertHorizLoop($block, 3, false, false); // Vertical
?>
What would change in your code? A lot. You'd need to add my function to your code (please don't forget to credit where you got it) and then in your while loop, instead of [man]extract[/man]ing the variables, you just want to take that array and add it to another array that will be sent to my function.
NOTE: While in the while() loop it may behoove you to go ahead and generate the output you want and then add it to the array.
Okay, so here's an example of your code with my function:
function vertHorizLoop($array, $cols=3, $horiz=true, $table=true)
{
$output = '';
// Define some defaults
$count = count($array);
if($table)
$output .= '
<table>
<tr>';
if(!$horiz)
{
$sect = array();
for($i=0; $i<$cols; $i++)
$sect[$i] = array();
$max = ceil($count/$cols);
$k=0;
for($i=0; $i<$count; $i++)
{
if($i%$max==0 && $i!=0)
$k++;
$sect[$k][] = $array[$i];
}
}
if($horiz)
{
for($i=0; $i<count($array); $i++)
{
if($i%$cols==0 && $i>0)
{
if($table)
$output .= '
</tr>
<tr>';
else
$output .= '<br>';
}
if($table)
$output .= '
<td>'.$array[$i].'</td>';
else
$output .= $array[$i].' ';
}
}
else
{
for($i=0; $i<$max; $i++)
{
foreach($sect as $key=>$arr)
{
if($table)
$output .= '
<td>'.$arr[$i].'</td>';
else
$output .= $arr[$i].' ';
}
if($table)
$output .= '
</tr>
<tr>';
else
$output .= '<br>';
}
}
if($table)
$output .= '
</tr>
</table>';
echo $output;
}
$theArray = array();
/*** YOUR CODE ***/
$getpress = mysql_query("SELECT * FROM events ORDER BY eventid ASC");
while($r=mysql_fetch_array($getpress)) {
$theArray[] = '<span style="color: #000; font-weight: bold;">'.$r['eventtitle'].'</span><br>
<span style="color: black;">'.$r['eventinfo'].'</span><br>
<span style="color: blue;">'.$r['eventlink'].' </span><br>';
}
// Now just output either a vertical or horizontal table:
vertHorizLoop($theArray, 2, 0, 1);
// Use $theArray to construct a 2 column NON-horizontal (Vertical) table
I also took the liberty of updating your code so instead of <font> you use <span>. Much cleaner and ready to go forward in development. But my above example should work for you.