DeFActo Posted May 3, 2008 Share Posted May 3, 2008 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 More sharing options...
sasa Posted May 3, 2008 Share Posted May 3, 2008 try while ($get_info = mysql_fetch_row($result)){ $field = $get_info[0]; print '<option value="'. $field. '>'.$field.'</option>'; } Link to comment https://forums.phpfreaks.com/topic/103981-solved-list-menu/#findComment-532372 Share on other sites More sharing options...
DeFActo Posted May 3, 2008 Author Share Posted May 3, 2008 Thanks sasa, it works. Link to comment https://forums.phpfreaks.com/topic/103981-solved-list-menu/#findComment-532375 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.