Hello all,
I've run into a problem with what seems to be a basic script. I want to display two different tables of data, side by side. Each table is built with a while loop, pulling data from an MySQL query. When I try to wrap the first table in a div the result is a div that appears empty when there is really a table with 60 rows of data I expect it to wrap around. I can't get this to work, I've tried to insert the div tag in many places to no avail.
Also, I wanted to add some blank space at the bottom of the page so that there was room between the end of the table and the actual bottom of the page. I tried adding some <br />'s at the end of the code but that didn't work.
I guess I'm confused because the code is acting as if the 60 rows of table data isn't there. When I tried to add my page layout around the script (as includes at the top and bottom of the script) the layout acts as if the table isn't there, either. That is to say that my "header" and "footer" appear bunched up at the top of the page as if there wasn't content on the screen.
Hopefully someone can help! Thanks.
<?php
echo "<br />
<a href='index.php'> Back Home </a>
<br />
<br />";
// -------------------------- Connect to DB
include ('connect_script.php');
// ------------------------------ Color variable for alternating table colors
$color = 1;
// ------------------------- Query Parameters
$select = "SELECT (number) AS id, (first_name) AS fn, (last_name) AS ln, (position) AS position FROM table WHERE position = 'X' ";
$get = @mysqli_query ($dbc, $select);
// ------------------------- Run Query
if ($get)
{
// ------------------------Start table
echo "
<div style='border-style: solid;'>
<table align='left' border='1'>
<tr>
<td>People</td>
</tr>
<tr>
<td>ID</td><td>First Name</td><td>Last Name</td><td>Position</td>
</tr>";
// ------------------------ Retrieve People
while ($row = mysqli_fetch_array($get, MYSQLI_ASSOC))
if ($color==1)
{echo ' <tr bgcolor= #47EA7D>
<td>' . $row['id'] . '</td><td>' . $row['fn'] . '</td><td>' . $row['ln'] . '</td><td>' . $row['position'] . '</td>
</tr>';
$color = '2';}
else
{echo ' <tr bgcolor= #A4C8B0>
<td>' . $row['id'] . '</td><td>' . $row['fn'] . '</td><td>' . $row['ln'] . '</td><td>' . $row['position'] . '</td>
</tr> ';
$color= '1';}
// ----------------------- Close table
echo "</div>
</table>";
mysqli_free_result ($get);
}
// -------------------- IF ERROR WITH QUERY
else
{echo "Didn't connect";}
// ---------------------- Spaces --> This is the code that doesn't appear to affect the space at the bottom of the table
echo "<br />
<br />
<br />";
?>