simjay
02-07-2006, 11:26 PM
Im not that good at PHP, have a look at this and i think ul find it funny but i aint got a clue. How would i make it list all the usernames?
<?php
$sql = "SELECT * FROM ALS_signup";
$result = mysql_query($sql, $conn) or die(mysql_error());
while ($newArray = mysql_fetch_array($result)) {
$username = $newArray['username'];
echo" <select name='test'>
<option>$username</option>
</select>
";
}
?>
SocoNaTromba
02-07-2006, 11:32 PM
You're missing the mysql_connect and database selection procedures.
simjay
02-07-2006, 11:42 PM
I have that,
I just need to know how to get the list menu working
firepages
02-08-2006, 12:39 AM
assumin you have a field in your database called 'username' then your code should work as-is , whats the problem you are having ?
simjay
02-08-2006, 12:41 AM
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/****/public_html/members/messages.php on line 508
firepages
02-08-2006, 02:13 AM
so $conn is not valid , do other queries fail or just this one ?
how do you connect to the database ? try just using
$result = mysql_query($sql) ;//without the $conn
if that fails show us your mysql_connect(); statement
Rich Pedley
02-08-2006, 11:23 AM
after you have sorted out the mysql problem you may want to redo things slightly:
<?php
$sql = "SELECT * FROM ALS_signup";
$result = mysql_query($sql, $conn) or die(mysql_error());
echo "<select name='test'>";
while ($newArray = mysql_fetch_array($result)) {
$username = $newArray['username'];
echo" <option>$username</option>";
}
echo "</select>";
?>
otherwise you will be creating a select box for each username.
degsy
02-08-2006, 02:38 PM
http://www.zend.com/php/beginners/php101-8.php#Heading5