Page 1 of 1

needed help with syntax

Posted: Wed Oct 14, 2009 5:22 pm
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)); 
} 
 

Re: needed help with syntax

Posted: Wed Oct 14, 2009 5:37 pm
by Christopher
You need to show us the generate_options() function.

Re: needed help with syntax

Posted: Wed Oct 14, 2009 10:51 pm
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); ?>

Re: needed help with syntax

Posted: Thu Oct 15, 2009 3:34 am
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

Re: needed help with syntax

Posted: Thu Oct 15, 2009 8:17 am
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