问题描述
- 怎样利用链接传过来的参数在第二个页面中用sql语句查找
-
a.php:<?php
$con = mysql_connect("localhost:3306","root","123456") or die("数据库连接失败".mysql_error());
mysql_select_db("vote",$con) or die ("数据库选择失败".mysql_error());
mysql_query("set names utf8");
?><?php for($i = 0; $i < 8; $i++) {?> <a href="b.php?id= <?php $a = mysql_query("select date from brief limit $i,1"); $b = mysql_fetch_array($a); echo $b["date"]; ?>"class="link" target="_blank" title="督导简报">2</a> <?php }?>
b.php:
<?php
$con = mysql_connect("localhost:3306","root","123456") or die("数据库连接失败".mysql_error());
mysql_select_db("vote",$con) or die ("数据库选择失败".mysql_error());
mysql_query("set names utf8");
$a = $_REQUEST['id'];
echo $a;
$b = mysql_query("select $a from brief");
$c = mysql_num_rows($b);
if($c > 0)
{
$sql = mysql_query("select * from brief");
$row = mysql_fetch_array($sql);
echo $row["title"];
echo $row["content"];
echo $row["time"];
}
?>我写的哪有错误?只对第一个参数查找怎样对第二个参数查找甚至第三个第四个等等。。
时间: 2024-10-31 19:29:26