How To Format Table Rows Into 2 Columns
Please excuse me if this question is elementary - fairly new to working with mysql. I left out the query and loop/references in the code below, because my question is on formatting
Solution 1:
td means table data which is basically a cell or column
tr stands for table row
The number of td inside your tr will determine how many columns you are going to get.
Also, have a look at the td attribute colspan and rowspanhere
In your specific case my guess is that you want to add another td inside your table
<tablewidth="85%"align="center"cellspacing="15"><tr><tdbgcolor="#dddddd"style="border:1px solid #000000; padding:12px"></td><tdbgcolor="#dddddd"style="border:1px solid #000000; padding:12px"></td></tr></table>
UPDATE: to loop through your data you need something like this
echo'<table width="85%" align="center" cellspacing="15">';
echo'<tr>';
$i = 0;
while(...) {
// skip the first iteration// then after every second <td> close the <tr> and open a newoneif($i > 0and$i % 2 == 0) {
echo'</tr><tr>';
}
echo'<td bgcolor="#dddddd" style="border:1px solid #000000; padding:12px"></td>';
$i++;
}
echo'</tr>';
echo'</table>';
Solution 2:
Try to avoid echo for html code, and use tr for rows and td for I shall post the code how it works for me:
?>
<tablewidth="85%"align="center"cellspacing="15"><?php//query,loop, references?><tr><tdbgcolor="#dddddd"style="border:1px solid black; padding:12px;"><formaction="index.php"method="get"><inputtype="hidden"name="page"value="viewproject"><inputtype="hidden"name="projectid"value="<?php$echo projectid;?>"><inputtype="submit"value="View Event"></form></td><td><formaction="jump_delete.php"method="post"align="right"><inputtype="hidden"name="projectid"value="<?php$echo projectid;?>"><inputtype="submit"value="Delete"></form></td></tr><tr><tdstyle="font-weight:bold; font-size:18px;"><?phpecho$projectclient;?></td><tdstyle="font-size:15px">
Event:<?phpecho$projectname;?></td></tr><tr><tdstyle="font-size:15px">
Date: <?phpecho$duedateformatted;?></td><tdstyle="font-size:15px">
Staff Count: <?phpecho$projectstaffcount;?></td></tr><?php//close loop?></table><?php
Solution 3:
tr add rows to you table td add cells inside a row tr
Assuming you need the additional cell after the second form, you will need an additional <td></td>
echo('<tablewidth="85%"align="center"cellspacing="15">');
//query,loop, references
echo('<tr><tdbgcolor="#dddddd"style="border:1px solid #000000; padding:12px"><divstyle="float:right"><formaction="index.php"method="get"><inputtype="hidden"name="page"value="viewproject"><inputtype="hidden"name="projectid"value="'.$projectid.'"><inputtype="submit"value="View Event"></form><br><formaction="jump_delete.php"method="post"align="right"><inputtype="hidden"name="projectid"value="'.$projectid.'"><inputtype="submit"value="Delete"></form></div>
// Additional td here
</td><td><divstyle="font-weight:bold; font-size:18px">'.$projectclient.'</div><divstyle="font-size:15px"><b>Event:</b> '.$projectname.'</div><divstyle="font-size:15px">Date: '.$duedateformatted.'</div><divstyle="font-size:15px">Staff Count: '.$projectstaffcount.'</div></td></tr>');
Post a Comment for "How To Format Table Rows Into 2 Columns"