mysqli_fetch_assoc从我的表中返回行,但它只显示表中的数据,直到表中的数据有空格。所以如果表格中有john scot,那么它只显示john。
php code
$query = "SELECT id, First_Name, Middle_Name, Surname, Maiden_Name, Death_Date, Birth_Date, Lot, Grave, Gender, Spouse_one, Spouse_two, Lot_Owner, Burial_Date, Section, Purchase_Price, Vet, Marker, Cremated, Purchase_Date, Notes FROM NovestaCem WHERE ".$searchname1." LIKE '%".$search1."%'
order by id";
$result = mysqli_query($conn, $query);
while($row = mysqli_fetch_assoc($result) ){
echo '<input type="hidden" name="id" value='.$row['id'].'><br/>';
echo "First Name: ";
echo '<input type="text" name="fname" value='.$row['First_Name'].'><br/>';
echo "Middle Name: ";
echo '<input type="text" name="mname" value='.$row['Middle_Name'].'><br/>';
echo "Surname: ";
echo '<input type="text" name="lname" value='.$row['Surname'].'><br/>';
echo "Maiden Name: ";
echo '<input type="text" name="Maiden_Name" value='.$row['Maiden_Name'].'><br/>';
echo "Death Date: ";
echo '<input type="text" name="ddate" value='.$row['Death_Date'].'><br/>';
echo "Birth Date: ";
echo '<input type="text" name="bdate" value='.$row['Birth_Date'].'><br/>';
echo "Burial Date: ";
echo '<input type="text" name="burdate" value='.$row['Burial_Date'].'><br/>';
echo "Gender: ";
echo '<input type="text" name="sex" value='.$row['Gender'].'><br/>';
echo "Spouse 1: ";
echo '<input type="text" name="Spouse_1" value='.$row['Spouse_one'].'><br/>';
echo "Spouse 2: ";
echo '<input type="text" name="Spouse_2" value='.$row['Spouse_two'].'><br/>';
echo "Section: ";
echo '<input type="text" name="sect" value='.$row['Section'].'><br/>';
echo "Lot: ";
echo '<input type="text" name="lot" value='.$row['Lot'].'><br/>';
echo "Plot: ";
echo '<input type="text" name="plot" value='.$row['Grave'].'><br/>';
echo "Lot Owner: ";
echo '<input type="text" name="lotowner" value='.$row['Lot_Owner'].'><br/>';
echo "Lot Purchase Date: ";
echo '<input type="text" name="lotpdate" value='.$row['Purchase_Date'].'><br/>';
echo "Lot Purchase Price: ";
echo '<input type="text" name="purprice" value='.$row['Purchase_Price'].'><br/>';
echo "Creamated: ";
echo '<input type="text" name="cream" value='.$row['Cremated'].'><br/>';
echo "Veteran: ";
echo '<input type="text" name="vet" value='.$row['Vet'].'><br/>';
echo "Notes: ";
echo '<input type="text" name="note" value='.$row['Notes'].'><br/>';
}
答案 0 :(得分:0)
生成 PROPER HTML。目前,您的脚本会生成此输出:
<input type="text" name="fname" value=john scot>
如果没有引号,浏览器将假定john
是值,scot
是属性。理想情况下,你应该做这样的事情:
echo sprintf('<input type="text" name="fname" value="%s"><br/>',
htmlspecialchars($row['First_Name']));