Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-07-2006, 11:26 PM   PM User | #1
simjay
Regular Coder

 
Join Date: Jul 2005
Posts: 153
Thanks: 1
Thanked 0 Times in 0 Posts
simjay is an unknown quantity at this point
list

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>
";

}

?>
simjay is offline   Reply With Quote
Old 02-07-2006, 11:32 PM   PM User | #2
SocoNaTromba
New Coder

 
Join Date: Jul 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
SocoNaTromba is an unknown quantity at this point
You're missing the mysql_connect and database selection procedures.
SocoNaTromba is offline   Reply With Quote
Old 02-07-2006, 11:42 PM   PM User | #3
simjay
Regular Coder

 
Join Date: Jul 2005
Posts: 153
Thanks: 1
Thanked 0 Times in 0 Posts
simjay is an unknown quantity at this point
I have that,

I just need to know how to get the list menu working
simjay is offline   Reply With Quote
Old 02-08-2006, 12:39 AM   PM User | #4
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,943
Thanks: 7
Thanked 82 Times in 81 Posts
firepages will become famous soon enough
assumin you have a field in your database called 'username' then your code should work as-is , whats the problem you are having ?
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
firepages is offline   Reply With Quote
Old 02-08-2006, 12:41 AM   PM User | #5
simjay
Regular Coder

 
Join Date: Jul 2005
Posts: 153
Thanks: 1
Thanked 0 Times in 0 Posts
simjay is an unknown quantity at this point
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/****/public_html/members/messages.php on line 508
simjay is offline   Reply With Quote
Old 02-08-2006, 02:13 AM   PM User | #6
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,943
Thanks: 7
Thanked 82 Times in 81 Posts
firepages will become famous soon enough
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
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
firepages is offline   Reply With Quote
Old 02-08-2006, 11:23 AM   PM User | #7
Rich Pedley
Regular Coder

 
Join Date: Sep 2005
Location: Liverpool
Posts: 226
Thanks: 0
Thanked 0 Times in 0 Posts
Rich Pedley is an unknown quantity at this point
after you have sorted out the mysql problem you may want to redo things slightly:
PHP Code:
<?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.
__________________
my mind is on a permanent tangent
Rich Pedley is offline   Reply With Quote
Old 02-08-2006, 02:38 PM   PM User | #8
degsy
Senior Coder

 
Join Date: Nov 2002
Location: North-East, UK
Posts: 1,265
Thanks: 0
Thanked 0 Times in 0 Posts
degsy is on a distinguished road
http://www.zend.com/php/beginners/php101-8.php#Heading5
degsy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:10 AM.


Advertisement
Log in to turn off these ads.