Charliejb Charliejb - 2 months ago 11
PHP Question

php changing the width of a table column

Having a few issues with changing my column width and changing it through

colspan='2'


works up till my while loop where it throws the error

Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';'


Any help, heres my code:

echo "<table border='0', width='100%'><tr><th colspan='2'>ID</th>
<th colspan='2'>First Name</th>
<th colspan='2'>Last Name</th><th colspan='2'>Location</th>
<th colspan='2'>Last Updated</th></tr>";
while($row = sqlsrv_fetch_array($results, SQLSRV_FETCH_ASSOC))
{

echo "<tr><td colspan='2'>" .$row['userID'].' </td><td colspan='2'> '.$row['first_name'].' </td><td colspan='2'> '
.$row['last_name'].' </td><td colspan='2'> '.$row['current_location'].' </td><td colspan='2'> '
.$row['last_updated']->format('Y-m-d H:i:s'). "</td><tr>";
}

echo "</table>";

Omi Omi
Answer

Your are doing wrong concatenation

paste this inside while loop:

echo "<tr><td colspan='2'>" .$row['userID']." </td><td colspan='2'> ".$row['first_name']." </td><td colspan='2'> "
        .$row['last_name']." </td><td colspan='2'> ".$row['current_location']." </td><td colspan='2'> "
        .$row['last_updated']->format('Y-m-d H:i:s'). "</td><tr>";

or

Simply use

<tr>
<td colspan='2'><?php echo $row['userID'];?>
<td colspan='2'><?php echo $row['first_name'];?></td>
<td colspan='2'><?php echo $row['last_name'];?></td>
<td colspan='2'><?php echo $row['current_location'];?></td>
<td colspan='2'><?php echo $row['last_updated']->format('Y-m-d H:i:s'); ?></td>
<tr>