rawky1976 Posted August 16, 2007 Share Posted August 16, 2007 Hello all I know you can't nest php tags so if you're already inside a code block and outputting a table via echo and want to popultate the value of a text box, how do you format the syntax? $result = @mysql_query($query); if (mysql_affected_rows() == 1){ $firstname = $result['user_fname']; The above gets a row, I'm not sure if the last line is necessary, now in the form what goes between the VALUE attribute to make it display the data from the query? echo "<tr><td>First Name</td><td><input type=\"text\" value=\"\" name=\"firstname\" id=\"firstname\" style=\"width: 160px\"/></td><td>Last Name</td><td> <input type=\"text\" value=\"$lastname\" name=\"lastname\" id=\"lastname\" style=\"width: 160px\"/></td></tr>"; I tried $firstname, $result['user_fname'], echo $firstname etc etc...? Link to comment https://forums.phpfreaks.com/topic/65246-solved-displaying-variables-without-nesting-php-tags/ Share on other sites More sharing options...
lightningstrike Posted August 16, 2007 Share Posted August 16, 2007 $result is simply a result identifier you need to fetch the actual data. $array = mysql_fetch_array($result); $firstname = $array["user_fname"]; Link to comment https://forums.phpfreaks.com/topic/65246-solved-displaying-variables-without-nesting-php-tags/#findComment-325806 Share on other sites More sharing options...
rawky1976 Posted August 16, 2007 Author Share Posted August 16, 2007 Thanks, that's worked Link to comment https://forums.phpfreaks.com/topic/65246-solved-displaying-variables-without-nesting-php-tags/#findComment-325835 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.