<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
<title>test</title>
</head><body>
<a href="show.php"?id=2004>link
</a>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
<title>test</title>
</head><body>
<a href="show.php"?id=2004>link
</a>
</body>
</html>
解决方案 »
- 将二维数组重新按条件重新生成新数组
- 请问,如何写PHP加密算法
- 高手来见识一下
- xml解析問題
- 大连 急召PHP,JSP或ASP工程师 英语 这个周六10/17号面试
- 小段代碼 提問...
- xajax晕晕晕,新手搞不定啊
- 要把一个数据库里的某几张表的结构和数据提取成.sql要怎么写
- wordpress侧边栏怎么调用的文章列表,看了很久一直不能理解
- 说说PHP板块的有关事情,今天过生日,也顺便庆祝一下,放分200!
- Php+MSSQL 查询10万以上记录出现错误码:Fatal error: Maximum execution time of 30 seconds exceeded in
- 大家好,我想学PHP,可否给俺带个路?
<a href="show.php?id="<?=$id?>>link
</a>
</body>
//数据库连接省略....
$id=10;
$query="select * from info where id='$id'";
$result=mysql_query($query);
while ($row=mysql_fetch_array($result))
{
print_r($row);
}
?>
不过我想问,上面的代码应该放在链接所在的页面下(index.php),还是结果显示的页面下(show.php)?
<?php
$id=2004;
$query="select * from info where id='$id'";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
while (is_array($row))
{
echo $row['字段名'];
}
?>
#index.php
#
<?php
$query="select id from `info`";
$result=mysql_query($query) or die("sql error");
while ($row=mysql_fetch_array($result))
{
echo <a href=show.php?id='.$row['id'].'>'.$row['id'].'</a>';
}
?>
#
#show.php
#
<?php
$ids=$_GET['id']; //传过来的id
echo $ids;
echo $_GET['id'];
//如果你还要继续查询别的东西,执行下面的程序
if(isset($ids)||!empty($ids)){
$query="select * from `info` where id='$ids'";
$result=mysql_query($query) or die("sql error");
while ($row=mysql_fetch_array($result))
{
echo '你在index.php点击的 id 是'.$row['id'];
echo '文章标题是'.$row['news_title'];//别的字段也可以这样实现
}
}else{
echo '非法操作';
}
?>