Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
while loop from database
Old 11-28-2005, 03:25 PM while loop from database
The_Anomaly's Avatar
Extreme Talker

Posts: 216
Location: Boston, Ma
Trades: 0
Last year i did alot with php for this project but it seems i forgot almopst everything. What i want to do is make a form. within this form i want to have a dropdown menu where the options are al the organization names in the database. I think i have to use a while loop and somehow compare an incrementing variable to the primary key within the database. I have no idea how i would code this. the only thing i could think of was:
Code:
$x=0;
while(SELECT orgname FROM organization WHERE orgId = $x){
echo "<option value=\"$orgName\">$orgName</option>";
$x++;
}
I know this cant be right. for one thing orgName doesnt come out of the databse as a variable. Also i'm not sure i can use a SELECT FROM WHERE within a while loop.

Can anyone help me out ?

Last edited by The_Anomaly; 11-28-2005 at 03:27 PM..
The_Anomaly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-29-2005, 05:10 AM
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
you need to do your query first then get a result set then use the while loop to iterate through your results.

I.E

$sql ="select name from users where id=1";
$resut = Execute(sql);

while($row=$result->FetchRow()){
// manage reults
}

Ibbo
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Linux user #349545 :
(GNU/Linux)iD8DBQBAzWjX+MZAIjBWXGURAmflAKCntuBbuKCWenpm XoA7LNydllVQOwCf
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Reply     « Reply to while loop from database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11124 seconds with 12 queries