dadamssg Posted January 16, 2009 Share Posted January 16, 2009 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>"; } ?> Quote Link to comment Share on other sites More sharing options...
gevans Posted January 16, 2009 Share Posted January 16, 2009 can u show the code you use to call it? Quote Link to comment Share on other sites More sharing options...
dadamssg Posted January 16, 2009 Author Share Posted January 16, 2009 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>"; Quote Link to comment Share on other sites More sharing options...
btherl Posted January 16, 2009 Share Posted January 16, 2009 echo "<tr> <td style='text-align: center; font-weight: bold'> Date & Time</td> <td>" . choosedatetime() . " </td> </tr>"; should work. Quote Link to comment Share on other sites More sharing options...
btherl Posted January 16, 2009 Share Posted January 16, 2009 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>"; Quote Link to comment Share on other sites More sharing options...
dadamssg Posted January 16, 2009 Author Share Posted January 16, 2009 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 Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 16, 2009 Share Posted January 16, 2009 Functions that generate content should actually return that content so that it can be used any way you need, rather than echoing that content in the function. Quote Link to comment Share on other sites More sharing options...
dadamssg Posted January 16, 2009 Author Share Posted January 16, 2009 well now it says the file choosedatetime.inc can't be found in my directory....i put it in the same folder as the other file and it pulled up and displayed everything else except the part of the form that is in choosedatetime.inc...what in the world... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.