I have 28 rows of data, i know how to display the data. The problem is that it lists the data in one column, I would like to display the 28 items within FOUR columns, equally. In the future I'll have more than 28 rows... data data data data data data data data data data data data data data data data Again, i would like the columns to contain the same amount of items, (unless it's an odd number of course) Thanks!
This is the code i'm using (php and mysql) <?php while($row = mysql_fetch_array($result)){ echo "<div id='sitetitle'>". $sitetitle. "</div>"; echo "<a href='". $loginurl. "'>L</a> | <a href='". $registerurl. "'>R</a> | <a href='". $phplink. "'>". $sitetitle. "</a><br><br>"; } ?> PHP:
i'm using this code to show my template names in 4 columns. Though it's a long process i think it may help you. Please let me know if you can use it <table align="center" width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td colspan="4">Latest Templates</td> </tr> <? $r = mysql_query("select * from product order by product_add_date desc"); for($i=0; $i < ceil(mysql_num_rows($r)/4); $i++){ $w = mysql_fetch_array($r); $tplID = $w['product_id']; $tplName = $w['product_name']; ?> <tr> <td width="130" valign="top"> <?=$tplID?> - <?=$tplName?> </td> <? $w = mysql_fetch_array($r); $tplID = $w['product_id']; $tplName = $w['product_name']; if($tplID != ""){ ?> <td width="130" valign="top"> <?=$tplID?> - <?=$tplName?> </td> <? } $w = mysql_fetch_array($r); $tplID = $w['product_id']; $tplName = $w['product_name']; if($tplID != ""){ ?> <td width="130" valign="top"> <?=$tplID?> - <?=$tplName?> </td> <? } $w = mysql_fetch_array($r); $tplID = $w['product_id']; $tplName = $w['product_name']; if($tplID != ""){ ?> <td width="130" valign="top"> <?=$tplID?> - <?=$tplName?> </td> <? } ?> </tr> <tr><td colspan="4"> </td></tr> <? } ?> </table>
Below is a piece of code which I use for a gallery page. It's lightly modified, hope you can use it. echo "<table width=100% cellspacing=1 cellpadding=6>"; while($query_data = mysql_fetch_array($result)) { if($i==0 || $i % 4==0) { echo "<tr align=center valign=top bgcolor=DFE7FF>"; } echo "<td width=25%> "; echo "<a href='index.php?id=".$query_data["event_id"]."&im=photo_gallery_d' class=blue>".$query_data["event"]."</a></td>"; if($i != 0 && ($i+1) % 4==0) { echo "</tr>"; } $i = $i + 1; } //fill up blank TDs $blank = false; for(; ($i%4 != 0); ) { echo "<td> </td>"; $i = $i + 1; $blank = true; } if($blank) echo "</tr>"; //fill up blank TDs echo "</table>"; PHP: