doujiku1028 2013-03-18 02:10
浏览 45

选择*来自'%item%'?

I have a drop down menu that I use to you choose from and this results in a value given to the next page. I would like to use this value to determine where to select from. So the possible values are car and toys. So I would like to let the user use the drop down menu to choose car which results in the database selecting from car to find the item.. If the user chooses toys I would have them select from toys in order to find the item. When I attempt to use this code I just get an error. If I delete '%item%' the error is gone. Any help would be loved. Thanks.

Submitting

<form action="search.php" method="post">
<select>
<option value>Choose A Item</option>
<option value="car" name="item">Car</option>
<option value="toys" name="item">Toys</option>
</select>
<input type="submit" name="submit" value="Submit" />
</form>

Searching

$term = $_POST['term'];
$item = $_POST['item'];

$query = mysql_query("select * from '%$item%' where Items like '%$term%'");
if(mysql_num_rows($query) <= 0)
{
echo "<center>No results. Please try another item.</center>";
} else {
while ($row = mysql_fetch_array($query)) {
echo "<p2>";
echo $row['Items'], ' - Location ' .$row['Loc'];
echo '<br/><br/>';
echo "</p2>";
}
}
?>
  • 写回答

2条回答 默认 最新

  • douqu8828 2013-03-18 02:13
    关注

    I think your query should be changed into: $query = mysql_query("select * from '$item' where Items like '%$term%'");

    评论

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题