Jump to content

Table Positioning using PHP


scipiovii

Recommended Posts

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

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%;

}

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.