Mysql中的PHP下拉列表,打印结果
我创建了一个下拉列表,并用Mysql填充了它。 我正在尝试获取用户选择的结果,以显示在两个不同的页面上 永久性的,但我不能让它工作 这是我的密码:Mysql中的PHP下拉列表,打印结果,php,mysql,drop-down-menu,selection,Php,Mysql,Drop Down Menu,Selection,我创建了一个下拉列表,并用Mysql填充了它。 我正在尝试获取用户选择的结果,以显示在两个不同的页面上 永久性的,但我不能让它工作 这是我的密码: <?php // Connect to the test datbase on localhost // That's where we created the countries table above mysql_connect('localhost','jakeray','pass'); mysql_select
<?php
// Connect to the test datbase on localhost
// That's where we created the countries table above
mysql_connect('localhost','jakeray','pass'); mysql_select_db('wordpress');
// Query the countries table and load all of the records
// into an array.
$sql = 'select * FROM manufacturers';
$res = mysql_query($sql) or die(mysql_error());
while ($rec = mysql_fetch_assoc($res))
$manufacturers[] = $rec;
?>
<?php
echo '<select action="select.php" name="dropdown" class="select">';
foreach ($manufacturers as $c)
{
if ($c['id'] == $_GET['id'])
echo "<option value=\"{$c['id']}\" selected=\"selected\">{$c['mfg']}, {$c['info']}</option>\n";
else
echo "<option value=\"{$c['id']}\">{$c['mfg']} {$c['info']}</option>\n";
}
echo '</select>';
?>
<?php
if(isset($_POST['select']))
{
$manufacturers=mysql_real_escape_string($_POST['dropdown']);
$result=mysql_query("SELECT FROM manufacturers");
$row=mysql_fetch_assoc($result);
print $row['mfg'];
}
?>
将$\u POST['select']
更改为$\u POST['dropdown']
。一旦他们选择了制造商,您可以:
将他们的选择存储在数据库中,如果他们登录,可能与他们的用户行关联
如果您使用的是PHP会话,请将其选择存储在$\u会话中
将数据存储在数据库中使用该数据库重新填充页面因此,当用户选择需要将数据发送到另一个数据库,然后发送到我希望显示的页面时?是的,如果要保留该数据,则必须将其存储在某个位置