PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Eiolon
Forum Newbie
Posts: 17 Joined: Tue Feb 14, 2006 1:42 pm
Post
by Eiolon » Tue Jul 20, 2010 4:34 pm
I have a table that is using while to show repeating results. The table is shown inside an echo, and I am having trouble getting it to work without error. I get:
Parse error: syntax error, unexpected '}' in C:\wamp\www\polaris\index.php on line 144
I am not sure why the } is unexpected.
Code: Select all
<?php if (isset($_POST['submit_search_polaris'])) {
echo '
<table class="data">
<tr>
<th><div align="left">Name</div></th>
<th><div align="left">Birthdate</div></th>
<th><div align="left">Gender</div></th>
<th><div align="left">Phone Number</div></th>
<th><div align="left">Barcode</div></th>
</tr>
'; do { '
<tr onmouseover="this.bgColor=#EBFAFF;" onmouseout="this.bgColor=#FFFFFF;">
<td>$PatronFullName</td>
<td>$Birthdate</td>
<td>$Gender</td>
<td>$PhoneVoice1</td>
<td>$Barcode</td>
</tr>
' } while ($row = mssql_fetch_assoc($result)); '
</table>
';
}
?>
JakeJ
Forum Regular
Posts: 675 Joined: Thu Dec 10, 2009 6:27 pm
Post
by JakeJ » Tue Jul 20, 2010 4:57 pm
It would help if we knew which line was 144.
I strongly suspect that it's the } near the bottom of the page though. Perhaps your opening and closing brackets aren't matching up. Check your pairs.
liljester
Forum Contributor
Posts: 400 Joined: Tue May 20, 2003 4:49 pm
Post
by liljester » Tue Jul 20, 2010 4:58 pm
you need to put 'echo' inside the loop. also dont forget to close the echo statement inside the loop. then echo the closing of the table as well.
liljester
Forum Contributor
Posts: 400 Joined: Tue May 20, 2003 4:49 pm
Post
by liljester » Tue Jul 20, 2010 5:01 pm
something like this:
Code: Select all
<?php
if (isset($_POST['submit_search_polaris'])) {
echo '
<table class="data">
<tr>
<th><div align="left">Name</div></th>
<th><div align="left">Birthdate</div></th>
<th><div align="left">Gender</div></th>
<th><div align="left">Phone Number</div></th>
<th><div align="left">Barcode</div></th>
</tr>
'; do { echo '
<tr onmouseover="this.bgColor=#EBFAFF;" onmouseout="this.bgColor=#FFFFFF;">
<td>$PatronFullName</td>
<td>$Birthdate</td>
<td>$Gender</td>
<td>$PhoneVoice1</td>
<td>$Barcode</td>
</tr>
'; } while ($row = mssql_fetch_assoc($result));
echo' </table>
';
}
?>
Eiolon
Forum Newbie
Posts: 17 Joined: Tue Feb 14, 2006 1:42 pm
Post
by Eiolon » Tue Jul 20, 2010 5:07 pm
Thanks!