【问题标题】:Html <A> link with variable带有变量的 Html <A> 链接
【发布时间】:2018-11-04 04:50:03
【问题描述】:

我正在尝试做这样的事情:

 <?php while($row = mysqli_fetch_assoc($result)) { ?>

    <li><?php echo $row["msg"] ;?>(id: <?php echo $row["msg_id"] ;?>) | sent at <?php echo $row["data"] ;?> <a href="message.php">see</a> | <a href="delete.php?msg_id=<?php $row["msg_id"]?>">delete</a></li>

 <?php 

    }
 ?>

但它不起作用。 msg_id 正确,数据库信息很好,但我不知道如何制作像delete.php?msg_id= $ROW_MSG_ID 这样的网址。 也许你可以帮助我。谢谢!

【问题讨论】:

  • 您只是在&lt;a&gt; 中的$row["msg_id"] 之前缺少echo。其他时间你都做对了。
  • @Barmar 哦,谢谢兄弟。我不小心。非常感谢
  • 你可以试试&lt;?php echo $a; ?&gt; 的简写和&lt;?= $a; ?&gt;只是一点建议
  • 请注意,通过 http get 删除可能很危险。浏览器可以预先获取您的项目并将其发送到比特桶!

标签: php html mysql phpmyadmin


【解决方案1】:
<?php
/* This code is a little bit hard to read.  
It would be much easier to troubleshoot if it is cleaner.  
Besides that, the problem could be your message.php or delete.php.  
This code is actually fine by itself. */?>


<li>
    <?php
        echo $row['msg'].'(id: '.$row['msg_id'].') | sent at '.$row['data'];
        echo '<a href="message.php">see</a> | '.
             '<a href="delete.php?msg_id='.$row['msg_id'].'">delete</a>';

    ?>

</li>

<?php
/* Output:
       * message(id: message_id) | sent at row_data see | delete.


// [link]see[/link to message.php] | [link]delete[/link to delete.php]

*/?>

【讨论】:

  • 感谢您的回答,但我发现了问题,我忘记了“回声”。我想做 delete.php?myvariable=12040
猜你喜欢
  • 2012-10-17
  • 1970-01-01
  • 1970-01-01
  • 2023-04-04
  • 1970-01-01
  • 2023-04-03
  • 2015-10-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多