php的数组传递

来源:百度知道 编辑:UC知道 时间:2024/06/30 03:23:08
我通过以下代码a.php输出一张表
while ($row = oci_fetch_array(....)){
print '<tr>';
print "<th>$row[0]</th>";
print "<th>$row[1]</th>";
print "<td><input type=\"submit\" name=\"bottom\" value="post"></td>"
print '</tr>';
}

希望通过单击按钮后把按钮的这一行数值传递到b.php

有什么方法没?
while ($row = oci_fetch_array(....)){
print '<tr><form method=post action=b.php>';
print "<th><input type=text name=r0 value='$row[0]'></th>";
print "<th><input type=text name=r1 value='$row[1]'></th>";
print "<td><input type='submit' value='post'></form></td>"
print '</tr>';
}

这个我试过了,不行
submit之后会把while取来的所有值都传过去,而不是传单独这一行,

要提交的东西,应该放在<input>里面才行,比如:
while ($row = oci_fetch_array(....)){
print '<tr><form method=post action=b.php>';
print "<th><input type=text name=r0 value='$row[0]'></th>";
print "<th><input type=text name=r1 value='$row[1]'></th>";
print "<td><input type='submit' value='post'></form></td>"
print '</tr>';
}

可用serialize()函数将数组字符串化,
然后用unserialize()处理一下,就把数组传到下个页面了.
page1:
<input type="hidden" name="array2string" value="<?=htmlspecialchars(serialize($array)) ?>">
page2:
$array = unserialize($_REQUEST["array2string"]);

同二楼咯
这种情况用GET可能比较合适吧:
<a href=\"yourfile.php?aaa=".$row[0]."\"><input type=\"button\" name=\"bottom\" value=&