scipiovii Posted October 14, 2008 Share Posted October 14, 2008 Hi, I have what I think is a relatively simple but frustrating PHP problem. I'm using PHP and MySQL, and when I fetch and display the results of my query using a while loop, i.e. ($row = mysql_fetch_array($result)) it displays the table, formatted the way I want it, but the longer the table, the more I have to scroll down to see it. In other words, it looks like it adds space between my last "true" html tag, and the actual table, proportional to the length of my table. It's noticeable but not too annoying unless I display tables of over 30 rows or so. This must be a simple formatting problem but I have yet to find an answer to this problem. Has anyone encountered something similar? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/128296-table-positioning-using-php/ Share on other sites More sharing options...
joecooper Posted October 14, 2008 Share Posted October 14, 2008 i am acually at the moment coding something simular - a table powered by php and mysql. post your code you have now and i might be able to help. Link to comment https://forums.phpfreaks.com/topic/128296-table-positioning-using-php/#findComment-664578 Share on other sites More sharing options...
dropfaith Posted October 14, 2008 Share Posted October 14, 2008 are you looping tables or rows in a table? also the more rows the more you need to scroll is kinda vague the more content the more page? post some relevant code to what your doing Link to comment https://forums.phpfreaks.com/topic/128296-table-positioning-using-php/#findComment-664580 Share on other sites More sharing options...
scipiovii Posted October 14, 2008 Author Share Posted October 14, 2008 Here's an example: I'm just including the formatting of the table so far - let me know if you need to see more of the code. I'm not a web designer, I'm more into the PHP and db stuff, so it could very well be an HTML anomaly, but it has happened on two separate sites, one using CSS and div tags, the other just a simple HTML template using tables instead of divisions. Anyway, here's the part of the code that displays the table, from a recipe database I'm working on: echo "<table class='one' border='0' >"; echo "<tr>"; echo "<th>Meal ID</th><th>Meal Name</th> <th>Nationality</th><th>Meal Category</th><th>Sub Category</th> <th>Main Ingredient</th><th>Origin</th>"; echo "</tr>"; while ($row = mysql_fetch_array($result1)) { echo "<tr>"; echo "<td>","<a href= 'page4.php?meal_ind=$row[meal_ind]'>", $row['meal_ind'], "</a>", "</td><td>", $row['name'], "</td> <td>", $row['nationality'], "</td><td>", $row['meal_cat'], "</td><td>", $row['meal_sub'], "</td> <td>", $row['main_ingt'], "</td><td>", $row['origin'], "</td>"; echo "</tr><br>"; } echo "</table>"; In case you're wondering, the Class "one" refers to the following CSS specs: .post .one { border-spacing: 10px; color: #44763E; text-align: center; font-size:50%; } Link to comment https://forums.phpfreaks.com/topic/128296-table-positioning-using-php/#findComment-664611 Share on other sites More sharing options...
R0bb0b Posted October 14, 2008 Share Posted October 14, 2008 You're looping a <br /> between your <tr> and </tr>. Since this is an invalid format, different browsers will display it differently, some may ignore it while others will stick it at the top of the table. Link to comment https://forums.phpfreaks.com/topic/128296-table-positioning-using-php/#findComment-664614 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.