Jump to content

Using Variables with HTML Forms


danik69

Recommended Posts

Hi

 

I am having a major problem with trying to get the HTML value attribute to display the a value stored in a array from SQL Query.

 

So i have done an SQL query then outputted it all to the screen, but i cant set the  value attribute on my HTML form to the variable $Name.

 

Can anyone please tell me where i am going wrong?

 

Thanks Nick

 



while($nt=mysql_fetch_array($result)){
echo "$nt[photo_url] $nt[Name] $nt[Education] $nt[skills] $nt[Aboutme] <br>";     // name class and mark will be printed with one line break at the end
}


$Photo_url = $_POST["photo_url"];
$Name = $_POST["Name"];
$Education = $_POST["Education"];
$Skills= $_POST["Skills"];
$Aboutme = $_POST["Aboutme"];
?>



<form method="post" action="updateaboutme.php">
Photo Url:<input type="text" size="12" maxlength="12" name="Photo_url" value="<?php echo $nt['Name'] ?>" <br /> 


<input type="submit" value="submit" name="submit">
</form> 

Link to comment
https://forums.phpfreaks.com/topic/210571-using-variables-with-html-forms/
Share on other sites

You're also missing the closing semicolon in the php within the value attribute of the input tag.  And I believe you should have quotes around the array keys in the second line.  Also, not going to break anything, but you should use <br /> instead of <br>

 

And of course, like the poster above said, you need to end your input tag with "/>"

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.