I am trying to build a table in php but i think i doing some mistake in the syntax.
<? php
echo '<table class="table table-bordered table-striped">'
echo '<colgroup>'
echo '<col class="col-xs-1">'
echo '<col class="col-xs-7">'
echo '</colgroup>'
echo '<thead>'
echo '<tr>'
echo '<th>Date</th>'
echo '<th>Title and Description</th>'
echo '</tr>'
echo '</thead>'
echo '<tbody>'
for ($num = 0; $num <= $data1; $num++) {
echo '<tr>';
echo '<td>'.$data1[$num] - > find('a', 0).'</td>';
echo '<td>'.$data[$num] - > find('a', 0).'</td>';
echo '</tr>';
}
echo '</tbody>'
echo '</table>' ?>
After each statement, you must use a semicolon (;
), you missed them on all of your statements. Also, you can mix HTML and PHP. Which makes it a lot cleaner:
<table class="table table-bordered table-striped">
<colgroup>
<col class="col-xs-1">
<col class="col-xs-7">
</colgroup>
<thead>
<tr>
<th>Date</th>
<th>Title and Description</th>
</tr>
</thead>
<tbody>
<?php
for ($num = 0; $num <= $data1; $num++) {
echo '<tr>';
echo '<td>'.$data1[$num]->find('a', 0).'</td>';
echo '<td>'.$data[$num]->find('a', 0).'</td>';
echo '</tr>';
}
?>
</tbody>
</table>
//try this
<?php
echo '<table class="table table-bordered table-striped">';
echo '<colgroup>';
echo '<col class="col-xs-1">';
echo '<col class="col-xs-7">';
echo '</colgroup>';
echo '<thead>';
echo '<tr>';
echo '<th>Date</th>';
echo '<th>Title and Description</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
for ($num = 0; $num <= $data1; $num++) {
echo '<tr>';
echo '<td>'.$data1[$num]->find('a', 0).'</td>';
echo '<td>'.$data[$num]->find('a', 0).'</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
?>
//or
<table class="table table-bordered table-striped">
<colxgroup>
<col class="col-xs-1">
<col class="col-xs-7">
</colgroup>
<thead>
<tr>
<th>Date</th>
<th>Title and Description</th>
</tr>
</thead>
<tbody>
<?php
for ($num = 0; $num <= $data1; $num++) {
echo '<tr>';
echo '<td>'.$data1[$num]->find('a', 0).'</td>';
echo '<td>'.$data[$num]->find('a', 0).'</td>';
echo '</tr>';
}
?>
</tbody>
</table>
//OR
Always use semicolon (;) at end of the statement. in php tag dont use space <?php /*your code*/ ?>