Re: Newbie ' If Statement' Question

From: Date: Wed, 19 Mar 2008 23:59:54 +0000
Subject: Re: Newbie ' If Statement' Question
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-271862@lists.php.net to get a copy of this message
heredoc is probably the best way to go. There's no way you can mess up your quotes, and you don't have to worry about escaping. Altough I wonder what would happen if you put ?> in a heredoc, would it stop processing the php, thinking that it was the end of the php file, or would it just treat it as a string still? - Dan "Al" <news@ridersite.org> wrote in message news:EA.9A.00283.00F6DD74@pb1.pair.com...
Here's how I'd do it. <?php $row= $emp_row->getRecordId();//Or, you can put this inside the heredoc with {} //heredoc $str= <<<txt <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="$row" /> <input type="submit" name="edit_submit" value="Activate" /> </form> txt; if (!empty($emp_row->getField('testfield')) print $str; else print "Non Print"; ?> cool7@hosting4days.com 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]


« previous php.general (#271862) next »