Lucky2710 Posted July 24, 2010 Share Posted July 24, 2010 i have a form that i only want to display between certain dates. So I'm calling a variable with the form inside it. but parts of the form are php controlled. am i going to have to echo all the html or is there a way to put php inside html inside the variable. Heres my code so u can see what I'm trying to do. $form = ('<h3><em style="color: #F00"> <?php echo $wk;?> <?php echo $wknum;?> </em></h3> <form name="ACC_wk1" method="post" action="cfb_acc_picks_process.php"> <p><br> <label> <input type="radio" name="game1" value="<?php echo ($away[0]);?>" "> <?php echo ($away[0]);?></label> at <label> <input type="radio" name="game1" value="<?php echo ($home[0]);?>" > <?php echo ($home[0]);?></label> <br> <label> <input type="radio" name="game2" value="<?php echo ($away[1]);?>" > <?php echo ($away[1]);?></label> at <label> <input type="radio" name="game2" value="<?php echo ($home[1]);?>" > <?php echo ($home[1]);?></label> </p> <p> <label> <input type="radio" name="game3" value="<?php echo ($away[2]);?>" > <?php echo ($away[2]);?></label> at <label> <input type="radio" name="game3" value="<?php echo ($home[2]);?>" > <?php echo ($home[2]);?></label> <br> <label> <input type="radio" name="game4" value="<?php echo ($away[3]);?>" > <?php echo ($away[3]);?> </label> at <label> <input type="radio" name="game4" value="<?php echo ($home[3]);?>" > <?php echo ($home[3]);?></label> <br> <label> <input type="radio" name="game5" value="<?php echo ($away[4]);?>" > <?php echo ($away[4]);?></label> at <label> <input type="radio" name="game5" value="<?php echo ($home[4]);?>" > <?php echo ($home[4]);?></label> <br> <label> <input type="radio" name="game6" value="<?php echo ($away[5]);?>" > <?php echo ($away[5]);?></label> at <label> <input type="radio" name="game6" value="<?php echo ($home[5]);?>" > <?php echo ($home[5]);?></label> <br> <label> <input type="radio" name="game7" value="<?php echo ($away[6]);?>" > <?php echo ($away[6]);?></label> at <label> <input type="radio" name="game7" value="<?php echo ($home[6]);?>" > <?php echo ($home[6]);?></label> <br> <label> <input type="radio" name="game8" value="<?php echo ($away[7]);?>" > <?php echo ($away[7]);?></label> at <label> <input type="radio" name="game8" value="<?php echo ($home[11]);?>" > <?php echo ($home[7]);?></label> <br> <label> <input type="radio" name="game9" value="<?php echo ($away[8]);?>" > <?php echo ($away[8]);?> </label> at <label> <input type="radio" name="game9" value="<?php echo ($home[11]);?>" > <?php echo ($home[8]);?></label> <br> <label> <input type="radio" name="game10" value="<?php echo ($away[9]);?>" > <?php echo ($away[9]);?> </label> at <label> <input type="radio" name="game10" value="<?php echo ($home[11]);?>" > <?php echo ($home[9]);?></label> <br> <label> <input type="radio" name="game11" value="<?php echo ($away[10]);?>" > <?php echo ($away[10]);?></label> at <label> <input type="radio" name="game11" value="<?php echo ($home[11]);?>" > <?php echo ($home[10]);?></label> <br> <label> <input type="radio" name="game12" value="<?php echo ($away[11]);?>" > <?php echo ($away[11]);?></label> at <label> <input type="radio" name="game12" value="<?php echo ($home[11]);?>" > <?php echo ($home[11]);?></label> <br> <br> <label> <input type="reset" name="button" id="button" value="Reset"> </label> <label> <input type="submit" name="button2" id="button2" value="Submit"> </label> <br> </p> </form>'); $date =("now"); if ( strtotime($date) > strtotime('18 July 2010') && strtotime($date) < strtotime('2 September 2010')){$wknum = '1'; $formDisplay = $form; $wk = "Week";} elseif ( strtotime($date) > strtotime('6 September 2010') && strtotime($date) < strtotime('11 September 2010')){$wknum = '2';$formDisplay = $form; $wk = "Week";} elseif ( strtotime($date) > strtotime('11 September 2010') && strtotime($date) < strtotime('16 September 2010')){$wknum = '3';$formDisplay = $form; $wk = "Week";} elseif ( strtotime($date) > strtotime('18 September 2010') && strtotime($date) < strtotime('23 September 2010')){$wknum = '4';$formDisplay = $form; $wk = "Week";} elseif ( strtotime($date) > strtotime('25 September 2010') && strtotime($date) < strtotime('2 October 2010')){$wknum = '5';$formDisplay = $form; $wk = "Week";} elseif ( strtotime($date) > strtotime('2 October 2010') && strtotime($date) < strtotime('9 October 2010')){$wknum = '6';$formDisplay = $form; $wk = "Week";} elseif ( strtotime($date) > strtotime('9 October 2010') && strtotime($date) < strtotime('16 October 2010')){$wknum = '7';$formDisplay = $form;$wk = "Week";} elseif ( strtotime($date) > strtotime('16 October 2010') && strtotime($date) < strtotime('23 October 2010')){$wknum = '8';$formDisplay = $form;$wk = "Week";} elseif ( strtotime($date) > strtotime('23 October 2010') && strtotime($date) < strtotime('28 October 2010')){$wknum = '9';$formDisplay = $form;$wk = "Week";} elseif ( strtotime($date) > strtotime('30 October 2010') && strtotime($date) < strtotime('4 November 2010')){$wknum = '10';$formDisplay = $form;$wk = "Week";} elseif ( strtotime($date) > strtotime('6 November 2010') && strtotime($date) < strtotime('13 November 2010')){$wknum = '11';$formDisplay = $form;$wk = "Week";} elseif ( strtotime($date) > strtotime('13 November 2010') && strtotime($date) < strtotime('20 November 2010')){$wknum = '12';$formDisplay = $form;$wk = "Week";} elseif ( strtotime($date) > strtotime('20 November 2010') && strtotime($date) < strtotime('27 November 2010')){$wknum = '13';$formDisplay = $form;$wk = "Week";} else{$formDisplay = $wk = " "; $formDisplay = ("<br><br><h2>Picks For this week are final!</h2> <br><br><br> Check Back Later To Make Your Picks For Next Week");} $result = mysql_query("SELECT * FROM ACC_Games_Table WHERE Week_Number='$wknum'"); while ($row = mysql_fetch_object($result)) { $away[] = $row->Away; $home[] = $row->Home; } Thanks Quote Link to comment https://forums.phpfreaks.com/topic/208790-php-inside-html-inside-a-php-variable-help/ Share on other sites More sharing options...
AbraCadaver Posted July 24, 2010 Share Posted July 24, 2010 The way you're doing it may not be the best way, but: eval("?>$form"); Quote Link to comment https://forums.phpfreaks.com/topic/208790-php-inside-html-inside-a-php-variable-help/#findComment-1090741 Share on other sites More sharing options...
webmaster1 Posted July 24, 2010 Share Posted July 24, 2010 I'm no expert myself but that seems like an unnecessarily complicated approach. Here's what I suggest instead: 1) Whatever the conditions are for the form appearing, create a variable and define it as TRUE. Here's the code. I've tested it for you. <?php // Add this to the end of whatever if/else statement you're using to prompt the form to appear. e.g. if isset // If the the form is submitted... if (isset($_POST['somebutton'])) { // Create the triggerform variable and define it as TRUE. $triggerform = TRUE; } // ?> <html> <body> Some content here..<br> Some content here..<br> Some content here...<br> <form name="someform" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="submit" name="somebutton" value="Trigger the form"><br> </form> <?php // If the triggerform variable is TRUE... if ($triggerform) { echo " <br> <br> <strong>Paste your form and php code here!</strong> <br> <br> "; } ?> Some content here..<br> Some content here..<br> Some content here.. </body> </html> 2) Remember that you can only use single quotes within the double quotes of this echo. e.g. style='color: #F00' but not style="color: #F00". The double quotes open and close the echo string. 3) The above example requires the posting of a button which may reset/erase whatever other forms you may be simultaneously using. This is beginning to sound a lot more like something you should be doing with JavaScript: http://www.cssnewbie.com/showhide-content-css-javascript/ Quote Link to comment https://forums.phpfreaks.com/topic/208790-php-inside-html-inside-a-php-variable-help/#findComment-1090757 Share on other sites More sharing options...
Lucky2710 Posted July 25, 2010 Author Share Posted July 25, 2010 thanks for yalls help Quote Link to comment https://forums.phpfreaks.com/topic/208790-php-inside-html-inside-a-php-variable-help/#findComment-1090785 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.