Jump to content

function? $variable?? what do i use?!


dadamssg

Recommended Posts

i created a date and time selection form and want to include it in a table multiple times...i tried putting it into a function but when i pull it up it just displays the function name that i tried calling "choosedatetime();". what can i put this into and call it out whenever i need it without having to repeat a lot of code. the html im tryin to display is below..thanks!

<?php
//choose datetime
function choosedatetime()
{
echo "
<HTML>
<BODY>
<B>START:  Day</B> 

<select name='month'> 
                                <option value='Jan'>Jan
                                   <option value='Feb'>Feb
                                     <option value='Mar'>Mar
                                        <option value='April'>April
                                        <option value='May'>May
                                        <option value='June'>June
                                        <option value='July'>July
                                        <option value='Aug'>Aug
                                        <option value='Sep'>Sep
                                        <option value='Oct'>Oct
                                        <option value='Nov'>Nov
                                          <option value='Dec'>Dec</select>
<B>/</B>


<select name='day'> 
                                <option value='01'>1
                                   <option value='02'>2
                                     <option value='03'>3
                                        <option value='04'>4
                                        <option value='05'>5
                                        <option value='06'>6
                                        <option value='07'>7
                                        <option value='08'>8
                                        <option value='09'>9
                                        <option value='10'>10
                                        <option value='11'>11
                                        <option value='12'>12
                                        <option value='13'>13
                                        <option value='14'>14
                                        <option value='15'>15
                                        <option value='16'>16
                                        <option value='17'>17
                                        <option value='18'>18
                                        <option value='19'>19
                                        <option value='20'>20
                                        <option value='21'>21
                                        <option value='22'>22
                                        <option value='23'>23
                                        <option value='24'>24
                                        <option value='25'>25
                                        <option value='26'>26
                                        <option value='27'>27
                                        <option value='28'>28
                                        <option value='29'>29
                                        <option value='30'>30
                                          <option value='31'>31</select>
<b>/<b>

<select name='year'> 
                                <option value='2009'>2009
                                   <option value='2010'>2010                                   
                                                                </select>

<B>   Time</B>

<select name='hour'> 
                                <option value='01'>1
                                   <option value='02'>2
                                     <option value='03'>3
                                        <option value='04'>4
                                        <option value='05'>5
                                        <option value='06'>6
                                        <option value='07'>7
                                        <option value='08'>8
                                        <option value='09'>9
                                        <option value='10'>10
                                        <option value='11'>11
                                        <option value='12'>12
                                                                </select>
<B>:</B> <select name='minute'> 
                                <option value='00'>00
                                   <option value='05'>05
                                     <option value='10'>10
                                        <option value='15'>15
                                        <option value='20'>20
                                        <option value='25'>25
                                        <option value='30'>30
                                        <option value='35'>35
                                        <option value='40'>40
                                        <option value='45'>45
                                        <option value='50'>50
                                        <option value='55'>55
                                                                </select>
  

<select name='minute'> 
                                <option value='am'>am
                                   <option value='pm'>pm                                   
                                                                </select>
             

</BODY>
</HTML>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/141009-function-variable-what-do-i-use/
Share on other sites

yeah, heres the part where im calling it...everything works and displays fine..except this...it just puts 'choosedatetime.inc;' in my table cell

 

echo "<tr>
       <td style='text-align: center;
                  font-weight: bold'>
    Date & Time</td>
       <td>choosedatetime();
</td>
       </tr>";

Actually, no it won't, because of the order of evaluation.  But you can do this:

 

echo "<tr>
       <td style='text-align: center;
                  font-weight: bold'>
    Date & Time</td>
       <td>";
choosedatetime();
echo "</td>
       </tr>";

i got an enexpected T_string error on line 10 in my choosedatetime.inc file....i noticed that i used double quotes when i echoed the html so i changed that...but i don't know what to do with line 10. And do i need cut out the <HTML><BODY> tags if this file will go into the other file that already has the <HTML><BODY> tags too? thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.