9999 Posted August 7, 2006 Share Posted August 7, 2006 On my index page I display the date and some "tips of the day" (tip.php-displayed in an iframe) derived from a delimited text file.[code] <div align="center" <?php echo date("<b>F j</b>"); ?> </div> [/code] [code]<?php //tip.php This displays on the index page in an iframe $file = file('data.txt'); $today = getdate(); echo'<table style="width:400px; height:200px; padding:0px; border:0px"><tr><td>'; foreach ($file as $line => $data) { list($month, $day, $year, $tip) = explode('|', trim($data) ); if ($today['month'] == $month AND $today['mday'] == $day) { echo '<font face="Times New Roman" size="2px">'. $tip .'</font>'; echo "<p>"; } } echo'</td></tr></table>'; ?> [/code] The iframehtml[code]<iframe name="iFrame1" width=425 height=225 src="tip.php" scrolling="auto" frameborder="0"></iframe>[/code]After viewing that, the view would then be able to select another day of the year and go to that result:html[code]<form action="select.php" method="POST"><select name="month"> <option value="January">January *** thru **** <option value="December">December</select><select name="day"> <option value="1">1 *** thru *** <option value="31">31</select> <input type="submit" name="Get Tip" value="Get Tip"/></form>[/code]That form submission then posts to select.php which is here:[code]<?php // from select.php $monthselect = $_POST['month']; $dayselect = $_POST['day']; $file = file('data.txt'); echo'<table style="width:400px; height:200px; padding:0px; border:0px"><tr><td>'; foreach ($file as $line => $data) { list($month, $day, $year, $tip) = explode('|', trim($data) ); if ($monthselect == $month AND $dayselect == $day) { echo '<font face="Times New Roman" size="2px">'. $tip .'</font>'; echo "<p>"; } } echo'</td></tr></table>'; ?> [/code] My problem is that this output is printed on a blank page. I want to display it as I do the original tip.php file that was displayed on my index page. I would prefer if this output was displayed on a regenerated index page. Any suggestions as to what code I would use? Using sessions was suggested but I don't know how I would implement that in my case. Is there another solution?I am a newbir to both php and web developing. I use two files instead of one and I use iframes because that is what I am comfortable with at this juncture.Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/16844-outputing-php-to-index-page-where-it-was-called-from/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.