Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
812 views
in Technique[技术] by (71.8m points)

javascript - How to show data from database into text in php

i want to show data from database into text box when i press select Button, but i am stuck on it , what i do next , Thanks in Advance

BootStrapCode

<td><label class="control-label" for="finame" id="myID1" >FIRST NAME</label></td>
<td><input type="text" class=" form-control2 input-sm text-uppercase"name="firstname" onkeypress="return allCharacter(event);" ></td>
<td><label  class="control-label" for="mname">MIDDLE NAME</label></td>
<td><input type="text" class=" form-control2 input-sm text-uppercase" name="middlename"></td>
<td><label  class="control-label" for="lname" id="myID2">LAST NAME</label></td>
<td><input type="text" class="  form-control2 input-sm text-uppercase" name="lastname" onkeypress="return allCharacter(event);"></td>

php Code

if (isset($_POST['select_button'])) {
  $qrydatabind1 = 'SELECT ecode, first_name, middle_name, last_name, father_name, mother_name,
              number_of_dependents, dob, gender, identification_mark, marital_status, spouse_name, mobile_number,
              email_id, adhar_id, pan_number, passport_number, tin_number, dl_number FROM USER_MASTER';
  $results1 = mysql_query($qrydatabind1) or die(mysql_error());

  while ($row = mysql_fetch_array($results1)) {
    echo '<td><input  type="text" value="{$row["first_name"]}" ></td>';
  }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There is a bug in the code. Change the while loop to this one:

while ($row = mysql_fetch_array($results1)) {
    echo '<td><input  type="text" value="' . $row["first_name"] . '" ></td>';
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...