Jump to content


Photo

Outputing php to index page where it was called from


  • Please log in to reply
No replies to this topic

#1 9999

9999
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts

Posted 07 August 2006 - 10:59 PM

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.

<div align="center"  
<?php  
   echo date("<b>F j</b>");  
?>  
</div>
 

<?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>';  
?>



The iframe

html
<iframe name="iFrame1" width=425 height=225 src="tip.php" scrolling="auto" frameborder="0"></iframe>

After viewing that, the view would then be able to select another day of the year and go to that result:


html
<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>

That form submission then posts to select.php which is here:

<?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>';  
?>


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!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users