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

时间:2014-11-18 12:50:03

标签: php html mysql

我想在锚点hreh中传递php值作为参数。这里我有问题,同时获取'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>";
          }
        ?>  

2 个答案:

答案 0 :(得分:3)

只需改变:

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

答案 1 :(得分:0)

尝试一下,希望它对您有用

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