Php 为什么我的
当我点击链接时,它无法工作 这是我的密码:Php 为什么我的,php,html,Php,Html,当我点击链接时,它无法工作 这是我的密码: if (mysql_num_rows($sql1)) { echo"<table>"; while ($row1 = mysql_fetch_array($sql1)) { if($row1['topic_id'] == $row['topic_id']){ echo "<tr><th><font color='blue'>".$row1['topi
if (mysql_num_rows($sql1)) {
echo"<table>";
while ($row1 = mysql_fetch_array($sql1)) {
if($row1['topic_id'] == $row['topic_id']){
echo "<tr><th><font color='blue'>".$row1['topic_name']."</th></tr> </font>";
echo"<a href='postreply.php?cat_id='$cat_id'&topic_id='$topic_id'&topic_creator='$topic_creator''>hi</a>";
}
}
echo "<tr><td>".$row['post_content']."</td></tr>";
echo"</table><hr>";
}
不需要“倍数”以及两者之间的间距?而cat也可能导致问题
echo"<a href='postreply.php?cat_id=$cat_id&topic_id=$topic_id&topic_creator=$topic_creator'>hi</a>";
试着
echo"<a href='postreply.php?cat_id=$cat_id&topic_id=$topic_id&topic_creator=$topic_creator'>hi</a>";
或者在脚本中添加以下停止传播的代码
$("#notificationContainer a").click(function(e)
{
e.stopPropagation();
});
你的报价违反了规则, 您需要对双引号进行转义,以便它们不会作为PHP代码读取。您可以通过在它们前面键入\字符来完成此操作 在上述代码中,修改如下:
echo"<a href='postreply.php?cat_id='$cat_id'&topic_id=\"$topic_id'&topic_creator=\"$topic_creator''>hi</a>";
不要在php echo中使用HTML标记,不要使用此标记;因为当您在更大的项目中使用这些代码时,可能会产生缩进、省略引号、分号等问题。请尽量保持代码的良好形式
另一方面,我建议您使用php类和对象,mysqli面向对象和预处理语句。这将有助于更好地编码
<?php
if (mysql_num_rows($sql1)){
?>
<table>
<?php
while ($row1 = mysql_fetch_array($sql1)) {
if($row1['topic_id'] == $row['topic_id']){
?>
<tr>
<th><font color='blue'><?php echo $row1['topic_name'];?></font></th>
</tr>
<a href="postreply.php?cat_id=<?php echo "cat_id=".$cat_id."&topic_id=".$topic_id."&topic_creator=".$topic_creator;?>">hi</a>
<?php
}
}
?>
<tr>
<td><?php echo $row['post_content'];?></td>
</tr>
</table>
<hr>
<?php
}
?>
当你在浏览器中查看页面源代码时,生成的HTML是什么样子?我无法单击,但正如我上面所问的,请查看浏览器中的页面源代码,如果你不清楚问题是什么,请告诉我们is@prozcay你能提供你的代码生成的html吗?谢谢,现在我可以点击,但它会返回到同一页,而不是postreply.php:@prozcay,点击它就可以了。这不是你想要的吗?点击hi,它应该转到'postreply.php?cat_id=$cat_id&topic_id=$topic_id&topic_creator=$topic_creator'@prozcay我正在检查你提供的网站链接,点击hi,它将进入postreply.php页面$cat_id、$topic_id和$topic_creator是否存在?是的,除了点击链接外,一切都正常,没有发生什么事
<?php
if (mysql_num_rows($sql1)){
?>
<table>
<?php
while ($row1 = mysql_fetch_array($sql1)) {
if($row1['topic_id'] == $row['topic_id']){
?>
<tr>
<th><font color='blue'><?php echo $row1['topic_name'];?></font></th>
</tr>
<a href="postreply.php?cat_id=<?php echo "cat_id=".$cat_id."&topic_id=".$topic_id."&topic_creator=".$topic_creator;?>">hi</a>
<?php
}
}
?>
<tr>
<td><?php echo $row['post_content'];?></td>
</tr>
</table>
<hr>
<?php
}
?>