PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 23rd, 2004, 02:17 PM
jaston72 jaston72 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 2 jaston72 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
syntax question

$question_01 = "selected";

this works fine...

PHP
<? print "<option value=\"01\" $question_01 > What is your father's middle name?";?>

this does not...

HTML
<option value="01" <? $question_01?> > What is your father's middle name?

is there a way in a option statement to include this variable inside the html brackets without
having to use php to parse the entire line?


Reply With Quote
  #2  
Old December 23rd, 2004, 03:08 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
It might be considered sloppy coding...
But i think this is what you're after:
<option value="01" <?=$question_01;?>> What is your father's middle name?</option>

Reply With Quote
  #3  
Old December 23rd, 2004, 03:13 PM
jaston72 jaston72 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 2 jaston72 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ty, thats the syntax i needed

Reply With Quote
  #4  
Old December 23rd, 2004, 04:22 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
no problem...
Just to clarify my "sloppy coding" comment...

The suggested way to set to set an option as selected is selected="selected"
this may seem odd, but that's how the W3C set their standards... its based on XML, attributes should be name/value pairs... thus, I'd recommend $question_01='selected="selected"';

Also, I question your variable $question_01... but I guess its being set by a database value, or maybe a $_POST or $_GET value... i'm sure you have that logic figured out =)

Glad to hear its working.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > syntax question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT