繁体   English   中英

如何在锚标签href中将php值作为参数传递

[英]how to pass php value as parameter in anchor tag href

我想将php值作为参数传递给锚hreh.Here获取'c_id'时出现问题。c_id是主键。 在这里,我附上了我的html代码和php代码

<?php
          include "config.php";
          $sql="select c_name from client order by c_name asc limit 10";
          $sql1=mysql_query($sql);
          echo "<table border='1' align=center width=500 style='border-collapse: collapse;'>";
           echo "<tr height =10><td width=300 align=center><b>Client name</b></td><td colspan=2 align=center><b>Action</b></td></tr>";
          while($fet=mysql_fetch_assoc($sql1))
          {
           $id=$fet['c_id'];
           echo "<tr>";
           echo "<td align=center width=100>".$fet["c_name"]."</td>";
           echo "<td align=center width=100><a href='client_details.php?id=".echo $id."'>Edit</a></td><td><a href=''>Delete</a></td>";
           echo "</tr>";  
           echo "</table><br>";
          }
        ?>  

只是改变:

echo "<td align=center width=100><a href='client_details.php?id=".echo $id."'>Edit</a></td><td><a href=''>Delete</a></td>";

至:

echo "<td align=center width=100><a href='client_details.php?id=".$id."'>Edit</a></td><td><a href=''>Delete</a></td>";

因为您已经使用过echo 不能使用echo另一个内部echo

试试这个,希望它对你有用

 <a href="your app url.php?data=phpvariable">Read more</a>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM