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 03-27-2007, 09:51 PM   PM User | #1
Darth Sensei
New Coder

 
Join Date: Mar 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Darth Sensei is an unknown quantity at this point
Dynamically creating a select control.

I have the basics of PHP fairly well and I have RTFM, but I simply cannot figure out what I'm doing wrong with this. I know it's prolly simple.

Can any of you gurus please point out the error of my ways?
Code:
$query = "Select RecID, ColCode, ColName, endcaps from colors WHERE endcaps = '1'"; 

$result = mysql_query($query);
//echo (mysql_num_rows($result));
while ($row = mysql_fetch_array($result)){
echo "<option value = \"{$row[1]}\">{$row[1]}</option>"
It throws parsing errors on the last line. I know I have a good result with 4 rows. The $row[1] has 3 digit numbers in it like 208, 209, etc.

I want the statement generated to be:
<option value="208">208</option>

Can anyone tell me what the hell I'm doing wrong?
Darth Sensei is offline   Reply With Quote
Old 03-27-2007, 09:59 PM   PM User | #2
Nightfire
Senior Coder

 
Nightfire's Avatar
 
Join Date: Jun 2002
Posts: 4,266
Thanks: 6
Thanked 48 Times in 48 Posts
Nightfire is on a distinguished road
PHP Code:
$query "Select RecID, ColCode, ColName, endcaps from colors WHERE endcaps = '1'"

$result mysql_query($query);
//echo (mysql_num_rows($result));
while ($row mysql_fetch_array($result)){
   echo 
"<option value = \"{$row[1]}\">{$row[1]}</option>";

It's also easier if you do it this way
PHP Code:
$query "Select RecID, ColCode, ColName, endcaps from colors WHERE endcaps = '1'"

$result mysql_query($query);
//echo (mysql_num_rows($result));
while ($row mysql_fetch_array($result)){
   echo 
'<option value="'.$row[1].'">'.$row[1].'</option>';

__________________
Blue Panda
Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
Nightfire is offline   Reply With Quote
Old 03-27-2007, 10:01 PM   PM User | #3
Darth Sensei
New Coder

 
Join Date: Mar 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Darth Sensei is an unknown quantity at this point
Thanks for the fast reply.
Darth Sensei 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 11:14 PM.


Advertisement
Log in to turn off these ads.