HTML within php file
Posted: Tue Mar 07, 2006 4:54 pm
feyd | Please use
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I have become lost in the tags <?php and ?> - When I added php in amongst html code I get a parse error - "unexpected $" and the line number is the line after the last line of the php file. I'm new to php, and am adding things in layers to ensure I get one layer working prior to moving on to the next. Things worked fine before I added the test "if ($lbPrimaryVoted)" and "if ($lbSecondaryVoted)"- which required my adding the <?php and ?> tags.
I'm trying to control what HTML is ouputed based on values in a database table. There are only three pieces of info I want to display:
1) a poll description
2) a submit button to either "display a poll", or "display results" (if the primary member has voted)
3) same as 2 (above), except for the secondary member.
At this point, the code snippet doesn't include the submit buttons.
Any help would be greatly appreciated.
MichaelCode: Select all
if (is_array($arPollIds))
{
foreach ($arPollIds as $nId)
{
$lcQuestion = $php_poll->get_poll_question($nId) ;
$lbPrimaryVoted = $php_poll->has_voted($nId, $lcUserName, $lcPrimaryName) ;
$lbSecondaryVoted = $lbSecondaryName and $php_poll->has_voted
($nId, $lcUserName, $lcSecondaryName) ;
?>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="100%" id="table1">
<tr>
<td width="50%"><b><font color="#6600FF"><?echo $lcQuestion; ?>
</font></b><br></td>
<?php
if ($lbPrimaryVoted)
{
?>
<td width="25%"> <? echo $lcPrimaryName; ?><br></td>
}
else
{
?>
<td width="25%"> <? echo "View Status"; ?><br></td>
}
<?php
if ($lbSecondaryVoted)
{
?>
<td width="25%"> <? echo $lcSecondaryName; ?><br></td>
}
else
{
?>
<td width="25%"> <? echo "View Status"; ?><br></td>
}
</tr>
</table>
</div>
<?php
}
}
else echo "Nothing to vote on" ;
?>feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]