3 回答
TA贡献1772条经验 获得超5个赞
以下应该工作。您混用了单引号,而您还不能设置Ca n't,所以需要将其括在“”中以转义单引号。我还在您的php中添加了“”并添加了句点。您需要查找有关php变量和字符串的更多教程。
$db=mysli_connect(null,null,null,'weblab')
or die("Can't connect to db:".mysqli_connect_error($db));
$q = "select tool_item_no, tool_name, tool_price, tool_weight";
$q .= "from tool_t";
$q .= "order by tool_name";
$dbResult = mysqli_query($db,$q)
or die("Database query error" . mysqli_error($db));
$num = mysqli_num_rows($dbResult);
if ($num == 0){
echo"<h3>No Data</h3>";
}
while ($row = mysqli_fetch_assoc($dbResult)) {
$tool_item_no = $row["tool_item_no"];
$tmool_name = $row['tool_name'];
$tool_price = $row['tool_price'];
$tool_weight = $row['tool_weight'];
echo "<label for = ".$tool_name.">Name : ".$toolname".<br/>Price : ".$tool_price."<br/>Weight : ".$tool_weight."<br/>How many
".$tool_name." for this order?
<input type = 'text name = ".$tool_name." id = ".$tool_item_no." size = ]'5'/></label><br/><br/>"
}
$db=mysli_connect(null,null,null,'weblab')
or die("Can't connect to
db:".mysqli_connect_error($db));
$q = 'select state_abbr, state_name ';
$q .= 'from state_t ';
$q .= 'order by state_name;';
$dbResult = mysqli_query($db,$q)
or die('Database query error' .
mysqli_error($db));
$num = mysqli_num_rows($dbResult);
if ($num == 0){
echo '<option value=
'$state_abbr' >$state_name</option>';
echo '<option>Error</option>';
}
while ($row = mysqli_fetch_assoc($dbResult)) {
$state_abbr = $row[state_abbr];
$state_name = $row[state_name];
echo '<option value= '.$state_abbr.'>
'.$state_name.'</option>';
}
- 3 回答
- 0 关注
- 196 浏览
添加回答
举报