php查询数据传值 php数据库查询语句( 二 )


/form
在另外一个页面这样获取值:
$name=$_POST['realname']; //这样在test.php页面就取到人名的值php查询数据传值了
其php查询数据传值他值同理
php做条件查询时的分页传值问题你这程序做得真不错php查询数据传值,但是还是乱?。?php查询数据传值我测试都没办法测试 。提出个问题php查询数据传值: $sel=$_POST['select'];
$sel2=$_POST['select2'];
你这样接收了两个变量,你这两个变量在每次刷新页数输出查询结果时,到底如何传递的 ?我发现你根本没有传递这两个变量;你测试下: $sel=$_POST['select'];
$sel2=$_POST['select2'];echo 'br/$sel'.$sel.'br/';echo '$sel2'.$sel2.'br/'; 建议:一开始使用post,已经输入后使用get,该select与select2通过html传输 。再则,你的查询条件:年代 , 类别 。(我不知道这两个是不是查询条件,看不出来 。。。。)是如何输入的?等你说明下你到底想实现什么样的功能再贴上来吧哥哥 。。。。。我帮你改了下,不知道能不能运行,自己测试下吧: ?php
include("conn.php");
if(isset($_POST['select']))//这里修改下
$sel=$_POST['select'];//这里修改下
else//这里修改下
$sel = $_GET['select'];//这里修改下
if(isset($_POST['select2']))//这里修改下
$sel2=$_POST['select2'];//这里修改下
else//这里修改下
$sel2 = $_GET['select2'];//这里修改下
if($sel=='' and $sel2=='')//这里修改下
$sql="select * from test";//这里修改下
elseif($sel!='' and $sel2=='')//这里修改下
$sql="select * from test where leibie like '%$sel%'";
elseif($sel=='' and $sel2!='')//这里修改下
$sql="select * from test where niandai like '%$sel2%'";
else
$sql="select * from test where leibie like '%$sel%' andniandai like '%$sel2%' ";
$result=mysql_query($sql);
$total=mysql_num_rows($result);
include("pageft.php");
pageft($total,10);
$info=mysql_query("$sql limit $firstcount,$displaypg");
if(!$info)
echo 'font size=6 color=red p align="center"没有您所要查找的内容,请重新查找!/p/font';
【php查询数据传值 php数据库查询语句】?table width="655" height="40" border="0" align="center"
tr
td width="680" align="right"span class="STYLE5 STYLE7"?phpif($info) echo $pagenav;?
/span/td
/tr
/table
table width="847" height="48" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000"
tr
td width="86" align="center"span class="STYLE1 STYLE8"名称/span/td
td width="85" align="center"span class="STYLE1 STYLE9"年代/span/td
td width="83" align="center"span class="STYLE1 STYLE8"类别/span/td
td width="495" align="center"span class="STYLE1 STYLE13 STYLE11"文物简介/span/td
td width="86" align="center"span class="STYLE1 STYLE11 STYLE13"图片/span/td
/tr
/table
?php
if($info)
while($row=mysql_fetch_array($info)){
$m=$m+1;
?
table width="844" height="51" border="1" align="center" cellspacing="0"
tr
td width="86" align="center"?php echo $m,"-",$row[name_db];?/td
td width="83" align="center"?php echo $row[niandai];?/td
td width="81" align="center"?php echo $row[leibie];?/td
td width="502" align="left"?php echo $row[remark];?/td
td width="80" align="center"a href="https://www.04ip.com/images/?php echo $row[image_db];?"target="_blank"img src="/images/defaultpic.gif"width='80' height='80' //td
/tr
/table
?php } ; ?
table width="838" height="75" border="0" align="center"
tr
td width="824" align="center" class="STYLE5 STYLE7" ?php if($info) echo $pagenav;?/td
/tr
/table/body
/html
下面的是分页代码?php

推荐阅读