我有这段代码:
<?php
session_start();
include_once 'include/dbconnect.php';
if(!isset($_SESSION['user']))
{
header("Location: ../index.php");
}
$dropdown = mysql_query("SELECT * FROM carros_real WHERE real_dono='".$_SESSION['user']."'");
while ($drop_row = mysql_fetch_array($dropdown)){
echo "<select>";
echo "<option value='".$drop_row['real_id']."'>" . $drop_row['real_marca'] . "</option>";
echo "</select>";
}
?>
结果是这样的: http://prntscr.com/9d1vpg
那么我打算做什么呢...我需要一个包含所有汽车的列表,我想将$ drop_row [&#39; real_id&#39;]发送到$ var。 我在这里缺少什么? 感谢
答案 0 :(得分:1)
<?php
session_start();
include_once 'include/dbconnect.php';
if(!isset($_SESSION['user']))
{
header("Location: ../index.php");
}
$dropdown = mysql_query("SELECT * FROM carros_real WHERE real_dono='".$_SESSION['user']."'");
echo "<select>";
while ($drop_row = mysql_fetch_array($dropdown)){
echo "<option value='".$drop_row['real_id']."'>" . $drop_row['real_marca'] . "</option>";
}
echo "</select>";
?>