Diogo Alpha
Diogo Alpha

Reputation: 23

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

Upvotes: 1

Views: 52

Answers (1)

Sugumar Venkatesan
Sugumar Venkatesan

Reputation: 4038

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

Upvotes: 1

Related Questions