简体   繁体   中英

Dropdown menu from mysql data

I have this code:

<?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>";
}
?> 

The Results are like this: http://prntscr.com/9d1vpg

Well what i intend to do its the oposite...i need a list with all cars and i want to send the $drop_row['real_id'] to a $var. What i am missing here? Thanks

<?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>";
 ?> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM