我尝试了几个插件尝试通过PHP和HTML表单将文本字段传递给另一个页面。如果表单中没有文本输入框,则表单将工作并显示输入的内容。最终目标是能够将这些变量传递到目标页面中的SQL查询。
if (isset($_POST['quantity']))
echo 'You selected ' . $_POST['quantity'] . '<br />';
$db = mysql_connect('localhost', 'username', 'password');
if (!$db) {
echo 'Error: Could not connect to database. Please try again.';
exit;
}
mysql_select_db('Stock');
$query = "select * from items limit 1";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
if ($num_results == 0)
echo 'No products found';
else
for ($i = 0; $i < $num_results; $i++) {
$row = mysql_fetch_array($result);
extract($row);
echo "<form method='post'>";
echo "ID: <input type='number' name='id' readonly value='$id'><br />";
echo "Name: <input type='text' name='name' value='$name'><br />";
echo "<input type='number' name='quantity' value='$quantity'><br />";
echo "<input type='submit' value='update'/>";
echo "</form>";
}