I'm trying to use a php function within a template html form that is being assigned as a php variable. I know that I can use standard $ variables and they will display ok, but I don't know how to use a function.
Essentially, I have a database with a set of values that I want to use to populate a drop down select form. I need to display the form in a couple of places so it makes sense to template the form with a variable.
So far I have the following PHP. Any help would be gratefully received! The array works fine - but displaying it within the form I'm struggling with.
$query = "SELECT property.propertyid, property.reference, property.userid, users.userid, users.username FROM property LEFT JOIN users ON property.userid = users.userid WHERE property.userid = ".$varuserid." "; $result = mysql_query($query) or die(mysql_error()); $listarr=array(); while($qy = mysql_fetch_array($result)){ $listarr[] = "<option value=\"".$qy['propertyid']."\">".$qy['reference']."</option>"; } $form = <<<HTML <form name="insert" method="post" action="?page=account&a=insert&form=1"> <table width="100%" border="0" cellpadding="4" cellspacing="0"> <tr> <td width="24%" align="left" valign="top">Property ID</td> <td width="76%"> <select name="propertyid" size="1"> foreach($listarr as $key => $value) { echo $value } </select> </td> </tr> <tr> <td align="left" valign="top"> </td> <td> <input name="userid" type="hidden" id="userid" value=$varuserid /> <input type="submit" name="submit" value="Insert transaction!" /></td> </tr> </table> </form> HTML;
Thanks,
Simeonenter code here