needed help with syntax

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
eliavozeri
Forum Newbie
Posts: 7
Joined: Sat Sep 19, 2009 1:40 pm

needed help with syntax

Post by eliavozeri »

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:

Code: Select all

 
<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:

Code: Select all

 
$return_string[]='<option value="'.$i.'">'.callback_month($i).'</option>';
 
the callback_month function looks like this:

Code: Select all

 
function callback_month($month) 
{     
        return date('M',mktime(0,0,0,$month,1)); 
} 
 
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: needed help with syntax

Post by Christopher »

You need to show us the generate_options() function.
(#10850)
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: needed help with syntax

Post by Eric! »

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); ?>
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: needed help with syntax

Post by jackpf »

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
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: needed help with syntax

Post by Eric! »

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
Post Reply