用于在变量中附加页面并在锚线中显示变量的php代码

时间:2014-12-19 13:50:15

标签: php

下面是我的链接代码

detail.php用于通过使用行ID显示行的详细信息。

我的问题是......是否可以在某个变量中传递完整链接,并且只能在每个链接上附加页面时访问此变量。

或任何我将我的页面名称detail.php和链接访问此功能的函数。 PLZ建议我......

例如 -

$ var = detail.php并使用此var如下链接。

 <a href="$var?id=<?php echo $row1['id']; ?>"></a>

不喜欢以下链接。 &#34;&GT;

1 个答案:

答案 0 :(得分:0)

不确定我是否正确理解了您的问题,但我认为这正是您所寻找的:

$rows; //variable with all database rows
$baseString = "details.php";
foreach ($rows as $row)
{
    $pageString = $baseString . "?id=" . $row['id'];
    ?>
    <h2><a href="<?php echo $pageString; ?>"><?php echo htmlspecialchars_decode($row['headline']); ?></a></h2>
    <?php
}