Php 如何从数据库中检索数据并使用其字符串将其显示在表单中?
我想知道如何将我从数据库中获取的数据显示到表单中。无论如何,这是我的代码:Php 如何从数据库中检索数据并使用其字符串将其显示在表单中?,php,html,mysql,database,forms,Php,Html,Mysql,Database,Forms,我想知道如何将我从数据库中获取的数据显示到表单中。无论如何,这是我的代码: <form action="" method="POST" style="height:350px; "> <?php while( $row = $result->fetch_assoc()){ ?> <label>First name</label> <input type="text" contenteditable="true" val
<form action="" method="POST" style="height:350px; ">
<?php while( $row = $result->fetch_assoc()){ ?>
<label>First name</label>
<input type="text" contenteditable="true" value="<?php echo $row['fname'];?>" class="fname" name="fname"/>
<label>Middle name</label>
<input type="text" contenteditable="true" value="<?php echo $row['mname'];?>" class="mname"name="mname"/>
<label>Last name</label>
<input type="text" contenteditable="true" value="<?php echo $row['lname'];?>" class="lname" name="lname"/>
<label>Gender</label>
<input type="text" contenteditable="true" value="<?php echo $row['gender'];?>" class="gender" name="gender"/>
<br><label>Birthdate</label>
<input type="text" contenteditable="true" value="<?php echo $row['bday'];?>" class="bday" name="bday"/>
<label>Civil Status</label>
<input type="text" contenteditable="true" value="<?php echo $row['cstatus'];?>" class="cstatus" name="cstatus"/>
<label>Citizenship</label>
<input type="text" contenteditable="true" value="<?php echo $row['cship'];?>" class="cship" name="cship"/>
<label>Addresss</label>
<input type="text" contenteditable="true" value="<?php echo $row['address'];?>" class="address" name="address"/>
<br><label>Contact Number</label>
<input type="text" contenteditable="true" value="<?php echo $row['cnumber'];?>" class="cnumber" name="cnumber"/>
<label>E-mail:</label>
<input type="text" contenteditable="true" value="<?php echo $row['email'];?>" class="email" name="email"/>
<label>Father's name:</label>
<input type="text" contenteditable="true" value="<?php echo $row['fathername'];?>" class="fathername" name="fathername"/>
<label>Contact number:</label>
<input type="text" contenteditable="true" value="<?php echo $row['fcontact'];?>" class="fcontact" name="fcontact"/>
<label>Mother's name:</label>
<input type="text" contenteditable="true" value="<?php echo $row['mothername'];?>" class="mothername" name="mothername"/>
<label>Contact number:</label>
<input type="text" contenteditable="true" value="<?php echo $row['mcontact'];?>" class="mcontact" name="mcontact"/>
<label>Guardian's name:</label>
<input type="text" contenteditable="true" value="<?php echo $row['gname'];?>" class="gname" name="gname"/>
<br><label>Contact Number:</label>
<input type="text" contenteditable="true" value="<?php echo $row['gcontact'];?>" class="gcontact" name="gcontact"/>
<label>Current/Last School Attended:</label>
<input type="text" contenteditable="true" value="<?php echo $row['lschool'];?>" class="lschool" name="lschool"/>
<?php
}
?>
名字
您可以添加生成当前$result
的代码和查询吗?$sql=“从注册表中选择fname、mname、lname、gender、bday、cstatus、cship、address、cnumber、email、fathername、fcontact、mothername、mcontact、gname、gcontact、lschool”$结果=mysqli_查询($db,$sql)@KevinStich不确定这是否是你要找的。查询和代码在上面。如果查询正在从寄存器中提取所有记录,请查看并优化它,以仅获取所需的行。我还需要在上面使用php吗@KevinStich还是我应该修复查询?您可以添加代码和生成当前$result
结果的查询吗?$sql=“从注册表中选择fname、mname、lname、gender、bday、cstatus、cship、address、cnnumber、email、fathername、fcontact、mothername、mcontact、gname、gcontact、lschool”$结果=mysqli_查询($db,$sql)@KevinStich不确定这是否是你要找的。查询和代码在上面。如果查询正在从寄存器中提取所有记录,请查看并优化它,以仅获取所需的行。我还需要在上面使用php吗@凯文斯蒂奇还是我应该修正这个问题?