当前位置: 移动技术网 > IT编程>开发语言>PHP > PHP获取input输入框中的值去数据库比较显示出来

PHP获取input输入框中的值去数据库比较显示出来

2017年12月12日  | 移动技术网IT编程  | 我要评论

前端:

<!--商品查询--> 
<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输入框中的值去数据库比较显示出来,希望对大家有所帮助

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网