user2148116
user2148116

Reputation: 195

Extract values from mysql and edit in php form

I have an edit form that retrieve person's information from database and fill them to textbox in a form to let the user to edit his info. , the problem is: when the field is a sentence (i.e. Full name) it prints only the first word(which is the first name). my code is:

  <label class ="label">Enter your full name</label>
          <input type="text" name="Name"  class="textbox" value= <?php echo $row["Name"]?> required/>

even though when I tried to echo $row["Name"], it prints it fully.

thanks in advance,

Upvotes: 1

Views: 28

Answers (3)

Rafiqul Islam
Rafiqul Islam

Reputation: 1646

Use value in double-quote $row['Name'] in single-quote

<label class ="label">Enter your full name</label>
      <input type="text" name="Name"  class="textbox" value="<?php echo $row['Name']?"> required/>

Upvotes: 1

PHP Geek
PHP Geek

Reputation: 4033

You can use as follows: suppose you have users table to store the user information then.

$query = mysql_query('select *from users where id=2'); //you can use dynamic 
$rec=mysql_fetch_array($query);
 <label class ="label">Enter your full name</label>
          <input type="text" name="Name"  class="textbox" value= <?php echo $rec["name"];?> required/>

where the name is the column name from database table

Upvotes: 1

Scoindy
Scoindy

Reputation: 131

I believe you're missing quotes around the value attribute, try:

 <label class ="label">Enter your full name</label>
      <input type="text" name="Name"  class="textbox" value="<?php echo $row["Name"]?>" required/>

Upvotes: 2

Related Questions