Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.