非常奇怪,为什么只能读出到content0_name,content1_weight这里,后面的数据都无法正确的显示出来,谁知道是为什么?谢谢!
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
</head>
<body>
<?php
require_once("../dataBase.php");
$sql="SELECT * FROM dishList_table WHERE dish_name='".$_GET["dish_name"]."'";
$result=$conn->query($sql);
if($result->num_rows>0){
$row=$result->fetch_assoc();
}else{
$_SESSION["caution_words"]="暂时没有这道菜";
header("location:./search_dish.php");
exit();
}
?>
//下面是搜索出来的结果,因为在录入菜品的时候限定了菜品名是不可以重复的,所以不用担心会有重复的数据
<form action="input_dish_back.php" method="post">
<table>
<tr>
<td id="split_line">菜品名称</td>
</tr>
<tr>
<td>
<input type="text" name="dish_name" value=<?php echo $row["dish_name"];?>>
</td>
</tr>
<tr>
<td id="split_line">菜品配方</td>
</tr>
<tr><td>成分名称</td><td>重量(g)</td><td>每100克热量(Kcal)</td><td>实际热量(kcal)</td></tr>
<tr>
<td><input type="text" name="content0_name" value=<?php echo $row["content0_name"]?>></input></td>
<td><input type="text" name="content0_weight" value=<?php echo $row["content0_weight"] ?>></input></td>
<?php
$sql="SELECT energy FROM foodList_table WHERE foodName='".$row["content0_name"]."'";
$result=$conn->query($sql);
if($result->num_rows>0){//这里加一个判断,排除是否将菜品的名称写错了,从而导致无法从数据库中获取
$row=$result->fetch_assoc();
$energy_0=$row["energy"];
$true_energy_0=$energy_0*$row["content0_weight"]/100;
echo '<input type="text" name="energy_0" value='</span>.<span class="hljs-variable">$energy_0</span> .<span class="hljs-string">'>
<input type="text" name="true_energy_0" value='</span>.<span class="hljs-variable">$true_energy_0</span>.<span class="hljs-string">'> ';
}else{
echo '<input type="text" name="energy_0" value=0>
<input type="text" name="true_energy_0" value=0> ';
}
?>
</tr>