Jump to content

[SOLVED] using colspan in echo statement


kevinritt

Recommended Posts

Hi,

When I display the data, the headings for each column don't line up with results. It looks like the 4 column headings are lining up with the first column and not spanning across 4 columns

<table id="poll_table" cellspacing="1" width="300">
<tr>
<td id="poll_heading">ID</td><td id="poll_heading">Q1</td><td id="poll_heading">Q2</td><td id="poll_heading">Q3</td>
</tr>
<?

$csql = "select * from poll_poll order by id asc ";

$cres = mysql_query($csql);

$num_rows = mysql_num_rows($cres);

$num_cols = mysql_num_fields($cres);

for($i=0; $i < $num_rows; $i++)

{
echo "<tr>";
$crow = mysql_fetch_array($cres);
for($j=0; $j < $num_cols; $j++)
{
  echo "<td colspan=\"4\" bgcolor=\"#ffffff\">";
  $field_name = mysql_field_name($cres, $j);
  echo $crow[$field_name];
  echo "</td>";
}

echo"</tr>";
}
?>
</table>

There are 4 fields being called from the database: ID, Q1(current), Q2(affiliation), Q3(rating)

Link to comment
https://forums.phpfreaks.com/topic/156482-solved-using-colspan-in-echo-statement/
Share on other sites

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.