constantin Posted January 10, 2010 Share Posted January 10, 2010 I whant to generate a tabel takeing data from database like this one so the results to be display on 2 columns <table width="50%" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td>Picture 1</td> <td>Details 1</td> <td width="30"> </td> <td>Picture 2</td> <td>Detalii 2</td> </tr> <tr> <td>Picture 3</td> <td>Details 3</td> <td> </td> <td>Picture 4</td> <td>Details 4</td> </tr> <tr> <td>Picture 5</td> <td>Details 5</td> <td> </td> <td>Picture 6</td> <td>Details 6</td> </tr> <tr> <td>Picture 7</td> <td>Details 7</td> <td> </td> <td>Picture 8</td> <td>Details 8</td> </tr> </table> Thank you Link to comment https://forums.phpfreaks.com/topic/187909-gerenate-tabel-in-php/ Share on other sites More sharing options...
The Little Guy Posted January 10, 2010 Share Posted January 10, 2010 Seeing that you have no code of your own start out with this, and see what you can do post if you have questions. http://beta.phpsnips.com/snippet.php?id=53 btw. please don't tell people to build something for you most people here wont thanks! Link to comment https://forums.phpfreaks.com/topic/187909-gerenate-tabel-in-php/#findComment-992175 Share on other sites More sharing options...
sasa Posted January 10, 2010 Share Posted January 10, 2010 <?php // echo table header echo "<table>\n<tr><td>Picture</td><td>Details</td><td> </td><td>Picture</td><td>Details</td></tr>\n"; $count = 0; while ($row = mysql_fetch_array($result)){ if ($count == 0) echo "<tr>\n"; $count++; // echo your data echo "<td>$row[picture]</td><td>$row[details]</td>\n"; if ($count < 2) echo "<td> </td>\n"; else { echo "</tr>\n"; $count = 0; } } if ($count) { for ($i = 0; $i < 2; $i++) echo "<td> </td>"; echo "</tr>\n"; } echo "</table>\n"; ?> Link to comment https://forums.phpfreaks.com/topic/187909-gerenate-tabel-in-php/#findComment-992233 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.