Jump to content

drop-down menu


Ph0enix

Recommended Posts

You can just pull the required information from your database, loop through it and create the entereies in the select box. Here's an example:
[code]<?php
$result = mysql_query("SELECT `name`,`id` FROM `table`") or die(mysql_error());
echo "<select name='names'>";
while($row = mysql_fetch_assoc($result)) {
    echo "<option value='$row[id]'>$row[name]</option>";
}
echo "</select>";
?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/10077-drop-down-menu/#findComment-37482
Share on other sites

Well its sort of working.
When i put this code in it works showing the points for users..

$result = mysql_query("SELECT `points` FROM `points`") or die(mysql_error());
echo "<select name='names'>";
while($row = mysql_fetch_assoc($result)) {
echo "<option value='$row[points]'>$row[points]</option>";
}
echo "</select>";

(the table is called points)

but when i try this code it comes up with the right amount of options but they all say Array[user_name]


$result = mysql_query("SELECT `user_name` FROM `points`") or die(mysql_error());
echo "<select name='names'>";
while($row = mysql_fetch_assoc($result)) {
echo "<option value='$row[user_name]'>$row[user_name]</option>";
}
echo "</select>";

Do you know whats wrong?
Link to comment
https://forums.phpfreaks.com/topic/10077-drop-down-menu/#findComment-37492
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.