On Fri, Mar 14, 2008 at 7:56 PM, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:

> Hello Folks,
>
> I would like to be able to wrap a 'form' inside a php 'if statement' -  so
> that the form will appear if the 'if condition' is met.
>
> -  most likely I cannot have a <?php tag inside another one - and am sure
> I'm doing other things wrong also...
> - now I get the error - Parse error: syntax error, unexpected T_STRING
> in...
>
> Q:  What is the best way to accomplish this goal?
>
>
> -----------------------
>
> <?php if ($emp_row->getField('testfield') !="") {
>    print "<form name="edit" method="post" action="emp_edit_result2.php">
> <input type="hidden" name="Status" value="Active"/>
> <input type="hidden" name="The_Date" value=""/>
> <input type="hidden" name="-recid" value="<?php echo
> $emp_row->getRecordId(); ?>">
> <input type="submit" name="edit_submit" value="Activate">
> </form>
>
> ";}else {print "Non Print";} ?>
>
>
>
> --
> Thanks - RevDave
> Cool7 @ hosting4days . com
> [db-lists]
>

Your first mistake I'm finding is the use of quotes. You started the print
with a ", which means the print ends at name=", and it's expecting more PHP
code, rather than a HTML string. The first fix would be to either escape all
quotes in the HTML with a slash (\) before it, or to change your opening and
closing quotes on the print to a single quote (').
Second, yes, you cannot enclose PHP tags inside PHP tags.  To do this,
change that portion to end the print, attach the two portions with a period
(.) and start up with the php function, then a period, and back to the
print.

Here's a fix that should work. I haven't tested it though, so I may have
missed one or two quotes.

<?php if ($emp_row->getField('testfield') !="") {
   print "<form name=\"edit\" method=\"post\"
action=\"emp_edit_result2.php\">
<input type=\"hidden\" name=\"Status\" value=\"Active\"/>
<input type=\"hidden\" name=\"The_Date\" value=\"\"/>
<input type=\"hidden\" name=\"-recid\" value=\""$emp_row->getRecordId()."\">
<input type=\"submit\" name=\"edit_submit\" value=\"Activate\">
</form>

";}else {print "Non Print";} ?>

Reply via email to