Forum Moderators: coopster
However, I want it to look more like the one I manually typed in: [1][2][3] Is there a way to get the results in a 3 column layout and then go down a row from there? Any help would be greatly appreciated! [1][edited by: eelixduppy at 6:32 pm (utc) on Dec. 2, 2007]
[2]
[3]
[4]
[5]
[6]
[4][5][6]
[edited by: nameless6135 at 6:36 pm (utc) on Dec. 2, 2007]
while($rows=mysql_fetch_array($result)){
?>
<font face="Arial, Helvetica, sans-serif" size="1"><table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="80%"><p><? echo $rows['company'];?><br><? echo $rows['raddress'];?><br><? echo $rows['phone'];?><br><? echo "<a href=".$rows['waddress'].">".Website."</a>";?> ¦ <? echo "<a href=".$rows['email'].">".Email."</a>";?> ¦ Map</p><br></td>
</tr>
</table>
</font>
<table id="view">
<tr>
<th>RMA</th>
<th>Filename</th>
<th>Date</th>
<th>Note</th>
<th>Delete</th>
</tr>
<?php
if (mysql_num_rows($filelist) > 0) {
while ($f = mysql_fetch_array($filelist)) {
?>
<tr>
<td>
<?php echo $f['status_name'];?>
</td>
<td>
<a href="<?php echo $_SERVER['PHP_SELF'];?>?action=dnld&id=<?php echo $f['id'];?>"><?php echo $f['filename'];?></a>
</td>
<td>
<?php echo $f['date'];?>
</td>
<td>
<?php echo $f['description'];?>
</td>
<td>
<a href="<?php echo ($_SERVER['PHP_SELF']);?>?delete_id=<?php echo $f['id'];?>">Delete</a>
</td>
</tr>
<?php
}
} else {
?>
<tr><td>No Files!</td></tr>
<?php
}
?>
</table>
$cols = 3; // put the number of columns you want here
$col_width = round(1/$cols * 100,0)."%"; // get column width as %
$extra_cells = "";
$num_rows = mysql_num_rows($result); // get number of records from query
$extra_needed = $cols-($num_rows % $cols); //find out how many blank cells there will be
if($extra_needed!= $cols ){
for($i = 0; $i<$extra_needed;$i++){
$extra_cells .= "<td width=\"$col_width\"> </td>\r\n"; // loop the blank cells in
}
}
if($result){
echo '<table width="80%" border="0" cellspacing="0" cellpadding="0">'."\r\n";
$tdcount = 1; //start cell count at one
while($rows=mysql_fetch_assoc($result)){
if($tdcount % $cols == 1) echo "<tr>\r\n"; // check to see if new row needs to be startedecho "<td width=\"$col_width\"><p>".$rows['company']."<br>".$rows['raddress']."<br>".$rows['phone']."<br><a href=\"".$rows['waddress']."\">Website</a> ¦ <a href=\"".$rows['email']."\">Email</a> ¦ Map</p><br></td>\r\n";
if($tdcount == $num_rows) echo $extra_cells; //echo extra cells into row
if($tdcount % $cols == 0) echo "</tr>\r\n"; // check to see if row needs to be ended$tdcount++; // add one to cell count
}
echo "</table> \r\n";
}