Php 通过URL传递值

Php 通过URL传递值,php,mysql,Php,Mysql,这就是我想要实现的目标;通过URL发送ID并打印 index.html 编辑query.php $result = mysqli_query($con,"SELECT * FROM List"); while($row = mysqli_fetch_array($result)) { echo $row['PID']; } $pid_q=$_GET[pid]; echo $pid_q; echo'; 当($row=mysqli\u fetch\u array($result))时,您

这就是我想要实现的目标;通过URL发送ID并打印

index.html

编辑query.php

$result = mysqli_query($con,"SELECT * FROM List");

while($row = mysqli_fetch_array($result))
{
  echo $row['PID'];
}
$pid_q=$_GET[pid];
echo $pid_q;
echo';
当($row=mysqli\u fetch\u array($result))时,您应该这样做
while($row = mysqli_fetch_array($result))
  {
  echo "<a href='receive.php?id=".$row['PID']."'>".$row['PID']."</a>";
  }
{ 回声“; } 如果要将自己的文本添加到变量或echo,请将其引用,并用“.”分隔变量。

如何

echo '<a href="print.php?id='. $row['PID'] . '">' . $row['PID'] . '</a>';
echo';

我相信这就是你的意思

while($row = mysqli_fetch_array($result))
{
    echo '<a href="print.php?' . $row['PID'] . '">Print ID: ' . $row['PID'] . '</a>';
}
while($row=mysqli\u fetch\u数组($result))
{
回声';
}
while($row=mysqli\u fetch\u数组($result))
{
echo“

”。$row['PID']”“

”; } $(文档).ready(函数(){ $(“#可单击”)。单击(函数(){ $(这个)…什么。。。 }); });

如果您希望每个PID都执行一些操作,而不是引用另一个位置,那么可以使用JQuery执行一些操作。它将使用clickable类监听任何。

记住在sql查询中使用参数之前检查参数,因为您现在所做的是易受攻击功能的最佳示例。一般提示:如果您遇到错误,请告诉我们错误是什么,并向我们展示导致它的代码。@iwo:这段代码中没有sql注入问题。查询中未使用任何外部数据。可能是因为我输入了错误的文件并弄乱了引号。:)
while($row = mysqli_fetch_array($result))
  {
  echo "<a href='receive.php?id=".$row['PID']."'>".$row['PID']."</a>";
  }
echo '<a href="print.php?id='. $row['PID'] . '">' . $row['PID'] . '</a>';
while($row = mysqli_fetch_array($result))
{
    echo '<a href="print.php?' . $row['PID'] . '">Print ID: ' . $row['PID'] . '</a>';
}
while($row = mysqli_fetch_array($result))
  {
  echo "<p id=".$row['PID']." class='clickable'>" . $row['PID'] . "</p>";
  }

$(document).ready(function(){
  $("#clickable").click(function(){
    $(this)...something...
  });
});