0
while($row=mysql_fetch_array($result))
{
   echo "<td>".$row['status']."</td>";
   echo "<td><a href='book.php?id='".$row['id'].">Book</a></td>";
}

在 book.php 页面中,我想获取在 url 中解析的 id="something" 的东西。有人可以帮助我吗?

书本.php

<?php
$id=$_GET['id']; // this is not right
echo $id;
?>
4

2 回答 2

2

尝试用这个替换

echo "<td><a href='book.php?id=".$row['id']."'>Book</a></td>";
于 2012-05-14T04:49:39.600 回答
0

如果您想要当前页面网址,请使用以下功能

function CurrentPageURL()
{
 $pageURL = $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://';
 $pageURL .= $_SERVER['SERVER_PORT'] != '80' ?     
 $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"] :   
 $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
 return $pageURL;
}

您只关心解析查询字符串,那么此链接可能会对您有所帮助

http://php.net/manual/en/function.parse-str.php

于 2012-05-14T05:02:53.677 回答