PHP编码的新手帮助我。
这是我的代码:
echo "<td id=\"row\" align=\"center\">" . $row['id'] . "</td>";
echo "<td id=\"title\" align=\"center\">" . $row['Title'] . "</td>";
echo "<td id=\"prodname\" align=\"center\">" . $row['ProductName'] . "</td>";
echo "<td id=\"amt\" align=\"center\">" . $row['Amount'] . "</td>";
$amt = $row['Amount'];
echo "<td id=\"row\" align=\"center\">" .
"<select id=\"testing\" onchange=\"GetSelected (this,$amt)\">
<option value=\"100\">100g</option>
<option value=\"250\">250g</option>
</select>" . "</td>";
echo "<td>" . "<input type=\"button\" value=\"Add\">" . "</td>";
点击“添加”按钮后,我需要将行值存储在数组或变量中。
答案 0 :(得分:0)
你可以这样编码
<form name="frm" method="POST" action="">
<table>
<tr>
echo "<td id=\"row\" align=\"center\">" . $row['id'] . "</td>";
echo "<td id=\"title\" align=\"center\">" . $row['Title'] . "</td>";
echo "<td id=\"prodname\" align=\"center\">" . $row['ProductName'] . "</td>";
echo "<td id=\"amt\" align=\"center\">" . $row['Amount'] . "</td>";
$amt = $row['Amount'];
echo "<td id=\"row\" align=\"center\">" .
"<select id=\"testing\" onchange=\"GetSelected (this,$amt)\">
<option value=\"100\">100g</option>
<option value=\"250\">250g</option>
</select>" . "</td>";
echo "<td>" . "<input type=\"SUBMIT\" value=\"Add\">" . "</td>";
</tr>
<table>
</form>
现在您可以将数组设为 $ _ POST 或 $ _ REQUEST
答案 1 :(得分:0)
我希望以下代码可以帮助您解决问题。
将此代码放在PHP脚本中
<? php
if ( $_GET["reg"] == "suc" )
{
$row['id']=$_GET["id"];
$row['Title']=$_GET["title"];
$row['prod']=$_GET["prod"];
$row['amount']=$_GET["amt"];
}
else
{
echo "try again";
}
echo "<form action=\"?reg=suc\" method=\"GET\">\n";
echo "Id: <input name=\"id\" ><br />\n";
echo "Title: <input type=\"text\" name=\"title\" ><br />\n";
echo "Productname: <input name=\"prod\" ><br />\n";
echo '<input type="checkbox" name="amt" value="100" >';
echo '<input type="checkbox" name="amt" value="250" > ';
echo "<input type=\"submit\" name=\"Add\">\n";
echo "</form>\n";
?>
如果单击“添加”按钮,这些值将存储在数组中 你可以用POST方法代替GET以隐藏的方式发送这些值!!!