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.

<?php

//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"];
}


?>
<html>

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

</body>

</html>

Thanks,
E.A.

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
or
2. Use <option> tag in your while.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.