Forum Moderators: coopster
I am creating a table and populating its cells with in a while loop. There are two queries involved and based on the value change of the first query, I go an get the data from the MySql table with the second query. My issue is when the tables get populated from the second table the cell sizes are different. How do I control the cell size the code is below.
Thank You
<?php
$sqlDistinct = "SELECT DISTINCT status from contracts ORDER BY Status";
if (!($resultstatus = @ mysql_query ($sqlDistinct, $connection)))
showerror();
while ($rowstatus = mysql_fetch_array($resultstatus, MYSQL_NUM))
{
$contractstatus = $rowstatus[0];
Print("CONTRACT STATUS: " . $contractstatus);
echo '<table width="115%" border="3" cellspacing="3" cellpadding="3">';
echo '<tr bgcolor="#666666">';
echo '<td width="6%"><font color="#CCFFFF">Contract Id</font></td>';
echo '<td width="6%"><font color="#CCFFFF">Contract Number</font></td>';
echo '<td width="6%"><font color="#CCFFFF">Vendor Number</font></td>';
echo '<td width="6%"><font color="#CCFFFF">Vendor Name</font></td>';
echo '<td width="2%"><font color="#CCFFFF">Group Id</font></td>';
echo '<td width="2%"><font color="#CCFFFF">Category</font></td>';
echo '<td width="6%"><font color="#CCFFFF">Specialist</font></td>';
echo '<td width="6%"><font color="#CCFFFF">Start</font></td>';
echo '<td width="6%"><font color="#CCFFFF">Finish</font></td>';
echo '<td width="46%"><font color="#CCFFFF">Comment</font></td>';
echo '</tr>';
$sql = "SELECT contracts.vnumber, contracts.vname, contracts.groupid, contracts.category, ".
"contracts.specialist, contracts.start, contracts.finish, contracts.comment, contracts.contractid, contracts.contractnbr ".
"FROM contracts WHERE contracts.status='".$contractstatus."'";
if (!($result = @ mysql_query ($sql, $connection)))
showerror();
// (4) While there are still rows in the result set, fetch the current row into the array $row
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
echo '<tr bgcolor="#999999">';
//Format the numbers
$vnumber=$row[0];
$vname=$row[1];
$groupid=$row[2];
$category=$row[3];
$specialist=$row[4];
$start=$row[5];
$finish=$row[6];
$comment=$row[7];
$contractid=$row[8];
$contractnmb=$row[9];
echo "<td>$contractid</td>";
echo "<td>$contractnmb</td>";
echo "<td>$vnumber</td>";
echo "<td>$vname</td>";
echo "<td>$groupid</td>";
echo "<td>$category</td>";
echo "<td>$specialist</td>";
echo "<td>$start</td>";
echo "<td>$finish</td>";
echo "<td>$comment</td>";
}
echo "</table>";
}
?>
In any case, this is really a job for CSS and a question for the HTML or CSS forums. What you need to do is get your layout to work on a static page. Then we can help you with how to generate that same code dynamically. First, though, you need code that works statically.