前端:
<!--商品查询--> <input type="text" name="bianhao" value="" maxlength="10" size="10" style="width:100px; margin:0px 0px 0px 25px;height:20px;"/> <input type="submit" value="商品编号查询" style="margin:0px 0px 0px 10px;cursor:pointer;background-color:#C30D23;border:0px;color:#FFFFFF;width:85px;border-radius:5px;padding:3px 0;font-size:13px;"/>
php后台接收并查询:
public function MallList(){ //写方法
$goods=M("shop_goods_info"); //实例化数据库对应的表
$codes=I("param.bianhao"); //获取前台文本框数据
if(isset($codes) && $codes != ""){
$where["code"]=$codes;
$this->assign("codes",$codes); //显示
}
}
$info=$classify->where(array("code"=>$code))->find(); //查询语法
2.或者:
有$_GET 或者 $_POST
<form action="" method="post">
文本框:<input type="text" name="text">
<input type="submit" value="提交",name="sub">
</form>
<?php
if(!empty($_POST["sub"])){
echo $_POST["text"];
}
?>
如果是GET 就换成GET
以上所述是小编给大家介绍的PHP获取input输入框中的值去数据库比较显示出来,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网页设计网站的支持!