0

So it's probably best to explain my project. The index.php page contains two iframes, one of which links to business.php which displays a BBC RSS feed. The second is meant to display the individual link for each article. So if one were to click on an individual title link in business.php; instead of being taken to that BBC page in that iframe, it actually creates a variable which is transferred back to index.php, then used as the source for the second iframe... I hope this makes sense, i'm currently attempting to use the SESSION function.

index.php

<?php
 if(!isset($_SESSION)) 
            { 
                session_start(); 
            } 
?>

<html>
<head>
    <link rel="stylesheet" type="text/css" href="style.css" /> 
</head>

<body>
<table>
    <col width="15%">
    <col width="42.5%">
    <col width="42.5%">
    <tr>
        <td id="bar">
            Rob's Edition

<ul>            
    <li><a href="index.php?$newsfeed='feeds/business.php'">Business</a></li>
    <li><a href="index.php?$newsfeed='feeds/technology.php'">Technology</a></li>
</ul>
        </td>

<td id="feed">



            <?php

            $newsfeed = "feeds/default.php";

            if (isset($_GET['$newsfeed'])) {
                $_SESSION['$newsfeed'] = $_GET['$newsfeed'];
            }
            echo isset($_SESSION['$newsfeed']) ? "<iframe src={$_SESSION['$newsfeed']} style='border:none' width='100%' height='100%' overflow-y='hidden' color='white'></iframe>" : 'Please choose a topic<br />';  

    ?>

    <td id='frame'> 
            <?php



            //echo isset($_SESSION['$framelink']) ? "<iframe src={$_SESSION['$framelink']} style='border:none' width='100%' height='100%' overflow-y='hidden' color='white'></iframe>" : 'Please choose a topic<br />';  



        echo ($_SESSION['$framelink']);
    ?>     
    </td>  

</body>
</html>

business.php

<?php
 if(!isset($_SESSION)) 
            { 
                session_start(); 
            } 

$framelink = ""
?>

<html>
<head>
    <link rel="stylesheet" type="text/css" href="style.css" /> 
</head>

<body>

<div>
<?php
$rss = simplexml_load_file('http://feeds.bbci.co.uk/news/business/rss.xml?edition=uk'); //BBC Business RSS Feed
$feed1 = "<h1>" . $rss->channel->title . "</h1>" . '<hr>'; //Title of feed 

foreach ($rss->channel->item as $item) {


    $framelink = $item->link;
    $feed1 .= '<h2><a href="business.php?' . $framelink . '">' . $item->title . '</a></h2>'; //Title of article
    $feed1 .=$item->description; //Description of article


}
?>


<?php
if (isset($_GET['$framelink'])) {
                $_SESSION['$framelink'] = $_GET['$framelink'];
            }

echo $feed1; 

?>
</div>
</body>
</html>
  • 2
    seems no good reason to use an iframe in the first place –  Jan 14 '16 at 19:54
  • @Dagon I used an iframe for business.php as i wanted a scrollable feed whilst the index.php remained fixed. As i'm new to php that seemed the easiest option. Do you have a way to display php with a scroll bar instead? – Rob Warneck Jan 14 '16 at 20:39
  • a div can have scroll bars –  Jan 14 '16 at 21:51
  • http://stackoverflow.com/questions/9707397/making-a-div-vertically-scrollable-using-css read this to learn how to use div for scroll bar. – jewelhuq Jan 14 '16 at 22:23

0 Answers0