PHP Results into two columns
Posted: Tue May 30, 2006 7:48 am
Hi Guys,
How would I sort my results into a table with two colmns,
I am looping though records in a MySQL DB and echoing out the results but I could really do with the results being layed out in two columns.
Code:
is what I currently have
and below is what I really need out.
Code:
here is my php
PHP Code:
Thanks for any help.
How would I sort my results into a table with two colmns,
I am looping though records in a MySQL DB and echoing out the results but I could really do with the results being layed out in two columns.
Code:
Code: Select all
<table width="100%" cellspacing="2" cellpadding="2">
<tr>
<td colspan="2" align="left" valign="top">'.$module.'</td>
</tr>
<tr>
<td width="5%" align="left" valign="top"><img src="'.$image.'"></td>
<td width="95%" align="left" valign="top">'.$description.'</td>
</tr>
</table>and below is what I really need out.
Code:
Code: Select all
<table width="100%" cellspacing="2" cellpadding="2">
<tr>
<td colspan="2" align="left" valign="top">'.$module.'</td>
<td colspan="2" align="left" valign="top">'.$module.'</td>
</tr>
<tr>
<td width="5%" align="left" valign="top"><img src="'.$image.'"></td>
<td width="31%" align="left" valign="top">'.$description.'</td>
<td width="5%" align="left" valign="top"><img src="'.$image.'"></td>
<td width="59%" align="left" valign="top">'.$description.'</td>
</tr>
</table>PHP Code:
Code: Select all
<?php
include_once("includes/connect.php");
$myemail = $_SESSION['myemail'];
$sql = "SELECT email, module, level, image FROM security WHERE email='$myemail' ORDER BY module ASC";
$r = mysql_query($sql);
if(!$r) {
$err=mysql_error();
print $err;
exit();
}
if(mysql_affected_rows()==0){
echo 'No Modules Available.';
exit();
}
else{
echo '<table width="100%" cellspacing="2" cellpadding="2">';
}
while ($line = mysql_fetch_array($r))
{
extract($line);
echo '<tr>
<td width="2%"><img src="images/'.$image.'" alt="'.$module.'"></td>
<td width="98%" class="Navigation">'.$module.'</td>
</tr>';
}
echo '</table>';
?>