PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Jan 16, 2018 9:49 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: needed help with syntax
PostPosted: Wed Oct 14, 2009 5:22 pm 
Offline
Forum Newbie

Joined: Sat Sep 19, 2009 1:40 pm
Posts: 7
hi guys i'm sort of having a problem with somthing (have been banging my head at the wall over this for some time) :banghead:
i have a page with a birthday field in it. now i don't want to write all the option tags so i kind of used a function to do the job for me but it doesn't seem to work.
i know the function works fine so i'm guessing my syntax is off.
thanks for the help and here is the code:

Syntax: [ Download ] [ Hide ]
 
<tr><td>Birthday</td><td>:</td>
<td>
  <select name="month">
     <option value="0">Month</option>
     <?php generate_options(1,12)?>
 </select>
</td>
</td></tr>
 


so as you can see the function returns a string with an option tag in it like so:
Syntax: [ Download ] [ Hide ]
 
$return_string[]='<option value="'.$i.'">'.callback_month($i).'</option>';
 

the callback_month function looks like this:
Syntax: [ Download ] [ Hide ]
 
function callback_month($month)
{    
        return date('M',mktime(0,0,0,$month,1));
}
 


Top
 Profile  
 
PostPosted: Wed Oct 14, 2009 5:37 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13468
Location: New York, NY, US
You need to show us the generate_options() function.

_________________
(#10850)


Top
 Profile  
 
PostPosted: Wed Oct 14, 2009 10:51 pm 
Offline
DevNet Resident

Joined: Sun Jun 14, 2009 3:13 pm
Posts: 1146
It would help to see your function, but just guessing at your intent I would say line 6 need to be something more like:
<?php echo generate_options(1,12); ?>


Top
 Profile  
 
PostPosted: Thu Oct 15, 2009 3:34 am 
Offline
DevNet Resident
User avatar

Joined: Sun Feb 15, 2009 8:22 pm
Posts: 2119
Location: Ipswich, UK
Eric! wrote:
It would help to see your function, but just guessing at your intent I would say line 6 need to be something more like:
<?php echo generate_options(1,12); ?>

You don't actually need the end semi colon. The php end tag is interpreted as a semi colon itself I believe...

Just an FYI :P


Top
 Profile  
 
PostPosted: Thu Oct 15, 2009 8:17 am 
Offline
DevNet Resident

Joined: Sun Jun 14, 2009 3:13 pm
Posts: 1146
Yeah either works. I actually debated whether or not to put it in and decided I didn't want to have him paste it and then try to add more lines and not understand why it didn't work. So for consistency I stuck it in there.... 8O


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group