PHP gets the value in the input box and compares it with the database to display it.

高洛峰
Release: 2023-03-03 14:00:01
Original
2909 people have browsed it

Front-end:

<!--商品查询-->
<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;"/>
Copy after login

php background receiving and querying:

public function MallList(){ //写方法
$goods=M(&#39;shop_goods_info&#39;); //实例化数据库对应的表
$codes=I(&#39;param.bianhao&#39;); //获取前台文本框数据
if(isset($codes) && $codes != &#39;&#39;){
$where[&#39;code&#39;]=$codes;
$this->assign(&#39;codes&#39;,$codes); //显示
}
}
$info=$classify->where(array(&#39;code&#39;=>$code))->find(); //查询语法
Copy after login

2. Or:

has $_GET or $_POST

<form action=&#39;&#39; method=&#39;post&#39;>
文本框:<input type=&#39;text&#39; name=&#39;text&#39;>
<input type=&#39;submit&#39; value=&#39;提交&#39;,name=&#39;sub&#39;>
</form>
<?php
if(!empty($_POST[&#39;sub&#39;])){
echo $_POST[&#39;text&#39;];
}
?>
Copy after login

If it is GET, change it to GET


Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template