Jump to content

[SOLVED] List menu


DeFActo

Recommended Posts

Hello,

I'm trying to make list menu that gets values from database. Here is my code

<form style="margin-left:300px" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<select name="name" onChange="this.form.submit()">
<option >----------</option>
<?php
$hostname="localhost";
$mysql_login=" ";
$mysql_password=" ";
$database="menu";

if (!($db = mysql_pconnect($hostname, $mysql_login , $mysql_password))){
  die("Can't connect to database server.");
}else{
    if (!(mysql_select_db("$database",$db))){
      die("Can't connect to database.");
    }
}
$result = mysql_query( "SELECT id FROM pavadinimai" );
while ($get_info = mysql_fetch_row($result)){
print '<option value="<?php foreach ($get_info as $field) ?>>"<?php echo "$field";?></option>';  }
?>
</select>
</form>

but i get as much empty fields instead of values as are records in database table. Could anyone help me, please?

Link to comment
https://forums.phpfreaks.com/topic/103981-solved-list-menu/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.