```
<head>
<meta charset="utf-8" />
<title>02.php</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div id="" class="form_box">
<form method="post">
<select name="select">
<optgroup label="根据-编号-索引查询">
<option value="id" >编号</option>
</optgroup>
<optgroup label="根据-类-索引查询">
<option value="class" >类</option>
</optgroup>
<optgroup label="根据-材料-索引查询">
<option value="material" >材料</option>
</optgroup>
<optgroup label="根据-名字-索引查询">
<option value="name" >名字</option>
</optgroup>
</select>
<input type="text" name="get" id="" value="" placeholder="输入需要查询的商品索引" />
<input type="submit" value="提交">
</form>
<div id="out" class="out_box">
<!-- php -->
<?php
$option_value=$_REQUEST['select'] ;
$input_value=$_REQUEST['get'];
// echo $option_value."<br/>";
// echo $input_value;
$con=mysqli_connect("localhost","test_connect_db","YNMxb8TjseznJ36F","test_connect_db");
if (mysqli_connect_errno($con))
{
echo "连接 MySQL 失败: " . mysqli_connect_error();
}
mysqli_select_db($con,"test_connect_db");
// $count=mysqli_fetch_row(mysqli_query($con,"select count(id) n from goods"))[0];//获取数据量
// $result=mysqli_query($con,"select *from goods ");
// $fieldinfo=mysqli_fetch_fields($result);
// foreach ($fieldinfo as $val)
// {
// printf($val->name);
// echo "<br>";
// printf("数据表: %s",$val->table);
// echo "<br>";
// printf("最大长度: %d",$val->max_length);
// echo "<br>";
// }
// if($option_value==null||$input_value==null){
// $result=mysqli_query($con,"select *from goods ");
// echo "全部商品";
// }
// else if($option_value!=$input_value){
$result=mysqli_query($con,"select *from goods where $option_value=
怎么才能实现动态获取数据库字段数组,并在随意输入索引时提示不存在?