用php获取动态输入值

时间:2013-04-03 16:31:17

标签: php

我需要在每个链接上创建包含不同名称的隐藏输入的链接。

 <?php
    $inputCounter=0;
    .. do while... 
    {
        $inputCounter++; ?>
        <a href="read.php">
            <input hidden name="rec<?php echo $inputCounter ;?>" 
                     value="<?php echo $id' ;?>"/>
            read    
        </a> 
    <?php } ?>

如何获取read.php中的输入值? 感谢您的任何帮助。

1 个答案:

答案 0 :(得分:2)

不要在锚标记中放置输入。使用查询字符串传递值。

<a href="read.php?name=rec<?=$inputCounter?>&value=<?=$id?>">read</a>

然后在read.php上,使用$_GET读取您的数据。

$name = $_GET['name'] // gives you the name
$value = $_GET['value'] // gives you the value

要回显该值,只需执行

echo $value;