Forum Moderators: coopster

Message Too Old, No Replies

Picklist and variables

         

VisLord

11:00 pm on May 11, 2005 (gmt 0)

10+ Year Member



I'm new to php but lost.
I'm tring to fill a picklist with data from mysql,
however failed miserably.

Going back to square one.

<? echo '<option value="12">Alabama</option>';?>

<? echo '<option value="99">',"$name",'</option>';?>

Why does the first work, and the second does not?
It outputs --- ,"$name",

How do I put the variable int the picklist.

Thanks........
VisLord

olwen

11:07 pm on May 11, 2005 (gmt 0)

10+ Year Member



Try:

<? echo '<option value="99">'.$name.'</option>';?>

VisLord

11:11 pm on May 11, 2005 (gmt 0)

10+ Year Member



I knew it was simple... Still learning.
What's the periods mean...
Thanks....

VisLord

olwen

12:43 am on May 12, 2005 (gmt 0)

10+ Year Member



The periods are concatenation. You are concatenating the strings (in single quotes) with the variable.

VisLord

1:05 am on May 12, 2005 (gmt 0)

10+ Year Member



Fantastic, now I can go back and repair things I sorta got working...

Thanks again....

VisLord

coopster

11:53 pm on May 13, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, VisLord.

PHP's manual pages are well-written. You'll find yourself going there quite often to find answers, too. Here are the pages on concatentation:

String Operators [php.net]