nameless6135

msg:3518783 | 6:14 pm on Dec 2, 2007 (gmt 0) |
| Here is the code I am using, sorry about now posting it in the first message. 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>
|
brancook

msg:3519486 | 6:51 pm on Dec 3, 2007 (gmt 0) |
Here is the way one of my tables looks. It's a 5 column layout. <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>
|
mooger35

msg:3519603 | 8:37 pm on Dec 3, 2007 (gmt 0) |
I've posted this in another thread before but I think this is what you are looking for. $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 started echo "<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"; } |
|
|
nameless6135

msg:3519791 | 11:50 pm on Dec 3, 2007 (gmt 0) |
mooger35: That is exactly what I was looking for. Thank you for the help.
|
|