I allow a member to create new styles for a program. They can save each style to a table called style_custom. A person can have more than one style in that table and the name of each can be found in the column called name. All I want to do is retrieve all of the styles that a member has from the style_custom table and put them in a drop memu. I'm using the belowe code and it is only listing one style from the table. NOTE: the member that I am querying has ten styles, but only one is showing up in the drop menu. When a member selects an item from the drop member the program will perform a given function when submit button is pressed. This is seemingly simple but I'm having a difficult time getting it to work.


//DB connection code here.... 

//$member stores the member name obtained from the seesion variable. This is created when
//member logs in....  This part works fine with the rest of the program.

//Run query
$q = "SELECT name FROM style_custom WHERE member = '$member'";
$r = mysqli_query($dbc, $q);

while ($row = mysqli_fetch_array($r)) {  
    $val = $row["name"];


        <select name="grab">
               <br /><option value="<?php echo $val ?>"><?php echo $val ?><br/></option>




9 Years
Discussion Span
Last Post by nav33n

Well, thats because only the last value is stored in variable $val because of the while loop.
You can
1. Put value of $row["name"]; to an array and iterate through that array in your select tag
2. Use <option> tag in your while.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.