Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,098
    Thanks
    297
    Thanked 12 Times in 12 Posts

    Exclamation Website Dilema? Using one page to populate many?

    Hi All,

    at the moment i have 5 pages all with the same code but one of the lines is different in every page telling the page which things to display, but would it be possible to have one page with all the info on it and have the 5 other pages set a session which would tell each of the pages what to display

    here is my pagedetails.php page
    PHP Code:
    <?php 
    session_start
    ();

    ini_set('display_errors',1);
    ini_set('display_startup_errors',1);
    error_reporting (E_ALL);?>
    <?php 
    require('_drawrating.php'); ?>
    <?php 
    require('functions.php'); ?>
    <?php 
    include_once('db101.php');?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>

    <meta name="keywords" content="kernow, connect, kernow connect, cheap, discount, shopping, saving, offers, online, cheapest, top, shops, bargain, discount codes, free"></meta>

    <meta name="description" content="Kernow Connect is a website dedicated in assisting your shopping needs by presenting the very best the web has to offer at discount prices, with over fifty of the best online stores rated and separated into five categories, online shopping has never been so easy."></meta>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <link rel="stylesheet" type="text/css" href="stylesheets/common_stylesheet.css"/>
    <link rel="stylesheet" type="text/css" href="stylesheets/category_stylesheet.css"/>
    <link rel="stylesheet" type="text/css" href="css/rating.css"/>

    <script type="text/javascript" language="javascript" src="js/behavior.js"></script>
    <script type="text/javascript" language="javascript" src="js/rating.js"></script>

    <title>Kernow Connect - helping you to become a smarter shopper.</title>

    <style type="text/css">
    <!--
    body {
        background-image: url(images/background.jpg);
        background-repeat: repeat-y;
        background-position:center;
    }
    -->
    </style>

    <!-- Google Analytics Code -->
    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    try {
    var pageTracker = _gat._getTracker("UA-4712023-1");
    pageTracker._trackPageview();
    } catch(err) {}</script>


    </head>
    <?php

        
    if (!$db_found) {
               die(
    'Could not connect: ' mysql_error());
        }
        
        
    mysql_query("SET NAMES 'utf8'");

        
    // ORDER STORES BY HIGHEST RATING FIRST 
        
    $sql "SELECT * FROM stores WHERE $cat_type  ORDER BY rating DESC";
        
    $result mysql_query($sql);
        
    $rows mysql_num_rows($result);

        if (!
    $result){
            print 
    "sql error on line 61. Please contact admin@kernow-connect.com to report this error";
        }

        
    //for each of the stores in the database
        
    for ($i 0$i $rows$i++) {
            
    $row mysql_fetch_array($result);    
            
    $storeID $row['storeID'];
            
    $storeName $row['name'];
            
    $stores[$i]=$storeName;
            
    $description $row['description'];
            
    $descriptions[$i] = $description;
            
    $storeURL $row['storeLink'];
            
    $storeURLs[$i] = $storeURL;
            
    $idReference "?sID=".$storeName
            
    $linkHTML "<a href = \"stores.php".$idReference."\">"
            
    $linkHTMLEnd "</a>";
            
    $urlStart "<a href='$storeURLs[$i]'>";
            
    $urlEnd "</a>";        
            
    $image $row['logo'];
            
    $imgres $image;
            
    $img_source $linkHTML  ."<img src='$imgres' alt='$storeName - More Top Items, Offers, New Releases and Discount Codes' border='0'/>".  $linkHTMLEnd;
            
    $logos[$i] = $img_source;
            
    $morelink "<a href = \"stores.php".$idReference."\">more</a>";
            
    $morelinks[$i] = $morelink;
            
    $feedtype $row['feedID'];
            
    $feedID[$i] = $feedtype;
            
            
    // GETTING THE TOTAL VALUES FROM ALL THE STORES
            
    $overall_rating "Select * FROM ratings WHERE storeID LIKE '$storeID'";  
            
    $rating_result mysql_query($overall_rating);  
            
    $rating_rows mysql_num_rows($rating_result);
            
    $votes $rating_rows['total_votes']; 
            
    $store_total $storeName.'total';
            
    $total 0;
                    
            
    //GETTING TOP ITEM INFO
            
    $rss_feed "SELECT
            s_FeedURL FROM rss_feeds 
            WHERE store = '$storeName' 
            AND description ='top'"
    ;
            
    $rss_result mysql_query($rss_feed); 
            
    $rss_row mysql_fetch_array($rss_result); 
            
    $rssIndividual[$i] = $rss_row['s_FeedURL'];
            
            
    $selectsql "SELECT
            s_itemList from rss_feeds
            WHERE description = 'top'
            AND s_FeedURL='$rssIndividual[$i]'"
    ;
            
    $sql_run mysql_query($selectsql) or die(mysql_error());
            
    $mysqlArr mysql_fetch_row($sql_run);
            
    $itemList explode("^",$mysqlArr[0]);//[0] determins the column number
            
    $test[$i] = $itemList;
            
    $item1[$i] = $itemList[0];

            
    //INSERTING VALUES
            
    while($row2 mysql_fetch_array($rating_result)){   
            
    $votes += number_format($row2['total_votes'],2);
            
    $total += number_format($row2['total_value'],2);
            
    $total_rating[$i] = $total;
            
    $total_votes[$i] = $votes;
                
            if ( 
    $votes == ){
                
    $overall_total 0;
            }
                else {
                    
    $overall_total number_format($total/$votes,2);        
                }
                    
            
    $avg_rating[$i] = $overall_total;
            
    $storeID $row2['storeID'];
            
            }
    //for while closing bracket start on line 120
              
            //INSERT NEW TOTALS INTO STORES TABLE
             
    $updateQuery "Update stores 
            SET rating = $overall_total 
            WHERE storeID = '$storeID'"
    ;
            
    $runupdate mysql_query($updateQuery);    
        
            
    //INSERT TOTALS INTO RATINGS TABLE
             
    $updateQuery2 "Update ratings 
            SET total_value = $total 
            WHERE storeID = '0' 
            AND id = '$store_total'"
    ;
            
    $runupdate2 mysql_query($updateQuery2);

            
    //total votes
            
    $updateQuery3 "Update ratings 
            SET total_votes = $votes 
            WHERE storeID = '0' 
            AND id = '$store_total'"
    ;
            
    $runupdate3 mysql_query($updateQuery3);

                  
            
    //GETTING THE NEWEST DISCOUNT CODES
            
    $codeSQL "SELECT * FROM codes 
            WHERE storeID = '$storeID' 
            AND expireDate >= date(now()) 
            ORDER BY expireDate ASC"
    ;
            
    $codeR mysql_query($codeSQL);

            if (!
    $codeR) {
                   die(
    'sql error on line 154 Please contact admin@kernow-connect.com');
            }
            
            
    $codeRows mysql_fetch_array($codeR);
            
    $code $codeRows['codeID'];
            
    $codes[$i] = $code;
            
    $codeDesc $codeRows['details'];
            
    $codesDesc[$i] = $codeDesc;
            
    $expire $codeRows['expireDate'];
            
    $expireDate $expire;
        
            
    //GET TODAYS DATE AND THE CODE DATES AND WORK OUT THE DIFFERENCE
            
    $today date("Y-m-d");
            
    $dateSQL "SELECT
             CASE
              WHEN ('$expireDate'='')
              THEN CONCAT( 'No Discount Codes Currently Available')
            WHEN (DATEDIFF('$expireDate',CURDATE( ))< '0')
              THEN CONCAT( 'Sorry Offer Has Ended' )
            WHEN (DATEDIFF('$expireDate', CURDATE( ))= '0')
             THEN CONCAT( 'Offer Ends', ' Today' )
            WHEN (DATEDIFF('$expireDate',CURDATE( ))= '1') 
              THEN CONCAT( 'Offer Ends', ' Tomorrow ' )
            ELSE
              CONCAT( 'Offer Ends In ', DATEDIFF('$expireDate','$today'), ' Days')
              END AS dateString"
    ;

            
    $dateRes mysql_query($dateSQL);
                    
            if (!
    $dateRes) {
                   die(
    'sql error on line 184 please contact admin@kernow-connect.com');
            }
            
            
    $daterow mysql_fetch_array($dateRes);
            
    $dateexp $daterow['dateString'];
            
    $expdate[$i] = $dateexp;
            
            }
    //closing bracket for Number of stores on line 70

        
    print"<body>";

        
    toplinks();

        print
    "<div id='info'>";
        for (
    $i 0$i 3$i++) {
            
            print 
    "<div class='featuredStore'>";
            print 
    "<div class='featuredLogo'>".$logos[$i]."</div>";
            print 
    "<div class='featuredRating'>".rating_bar($stores[$i].'total','5','static')."Average Rating <b>$avg_rating[$i]</b> (<font color='red'><b>$total_votes[$i]</b> Votes</font>)</div>";
            print 
    "<div class='featuredDescription'>";

            
    //display limited text for the description
            
    $position=110// Define how many characters you want to display.

            
    $message=$descriptions[$i]; 
            
    $post substr($message,$position,1); // Find what is the last character displaying. We find it by getting only last one character from your display message. 

                
    if($post !=" "){
                
    // In this step, if last character is not " "(space) do this step . 
                // Find until we found that last character is " "(space) 
                // by $position+1 (14+1=15, 15+1=16 until we found " "(space) that mean character 20) 
                    
    while($post !=" "){
                    
    $a=1;
                    
    $position=$position+$a
                    
    $message=$descriptions[$i];
                    
    $post substr($message,$position,1); 
                    }
                }

            
    $post substr($message,0,$position); // Display your message
            
    print $post;
            print 
    "... ";
            print 
    $morelinks[$i];
            print 
    "</div>";//description closed
        
            
    print "<div class='recommends'>";
            
    //Top items info
            
    if ($rssIndividual[$i] == ''){
                print 
    "Sorry No Information Currently Available";
            }
        
                elseif (
    $feedID[$i] == '1'){
            
                
    $feedurl $rssIndividual[$i];
                
    $xml=simplexml_load_file($feedurl);
                
    $count 1;    
                
                    foreach (
    $xml->merch->prod as $item){
                    
    $desc html_entity_decode($item->desc);
                        
                        if (
    in_array($item->pId,$test[$i])){
                            if(
    $count 0){
                            
                            echo
    "
                            <div class='inditemheader'>
                            <a href='{$item->awLink}'>{$item->name}</a></div><br />
                    
                            <div class='inditemimg'>
                            <a href='{$item->awLink}'>
                            <img src='{$item->mImage}' 
                            alt='{$item->name}' 
                            height='100' 
                            border='0' 
                            vspace='0'/></a>
                            </div>
                    
                            <div class='inditemdesc'>$desc</div><br />
                            <div class='inditemprice'>Buy Now For £{$item->price->search}</div>
                            <div class='inditeminfo'><a href='{$item->awLink}'>More Info</a></div>"
    ;  
                            
    $count--;        
                                 }
                          }
                    }
                }
              
                  elseif (
    $feedID[$i] == '2'){
            
                
    $feedurl $rssIndividual[$i];
                
    $xml=simplexml_load_file($feedurl);
                
    $count 1;    
                
                    foreach (
    $xml->product as $item){

                        if (
    in_array($item->TDProductId,$test[$i])){
                            if(
    $count 0){
                                echo
    "
                                <div class='inditemheader'>
                                <a href='{$item->deepLink}'>{$item->productname}</a></div><br />
                    
                                <div class='inditemimg'>
                                <a href='{$item->deepLink}'>
                                <img src='{$item->imageURL}'
                                alt='{$item->productname}' 
                                height='100' 
                                border='0' 
                                vspace='0'/></a>
                                </div>
                    
                                <div class='inditemdesc'>{$item->description}</div><br />
                                <div class='inditemprice'>Buy Now For £{$item->Price}</div>
                                <div class='inditeminfo'><a href='{$item->deepLink}'>More Info</a></div>"
    ;                              $count--;  
                            }  
                        }
                    }                    
                }
                
                              elseif (
    $feedID[$i] == '3'){
            
                
    $feedurl $rssIndividual[$i];
                
    $xml=simplexml_load_file($feedurl);
                
    $count 1;    
                
                    foreach (
    $xml->merchant->prod as $item){

                        if (
    in_array($item->pId,$test[$i])){
                            if(
    $count 0){
                                echo
    "
                                <div class='inditemheader'>
                                <a href='{$item->uri->awTrack}'>{$item->text->name}</a></div><br />
                    
                                <div class='inditemimg'>
                                <a href='{$item->uri->awTrack}'>
                                <img src='{$item->uri->mImage}'
                                alt='{$item->text->name}' 
                                height='100' 
                                border='0' 
                                vspace='0'/></a>
                                </div>
                    
                                <div class='inditemdesc'>{$item->text->promo}</div><br />
                                <div class='inditemprice'>Buy Now For £{$item->price->buynow}</div>
                                <div class='inditeminfo'><a href='{$item->uri->awTrack}'>More Info</a></div>"
    ;                              $count--;  
                            }  
                        }
                    }                    
                }


                   elseif (
    $feedID[$i] == 'amazon'){

                
    // Get XML 
                
    $xml=simplexml_load_file("http://www.amazon.co.uk/rss/bestsellers/videogames?tag=kernconn-21");

                
    // How many items to display from the RSS Feed ...
                
    $count 0

                    foreach (
    $xml->channel->item as $item) { 
                        
    $link trim($item->link);
                        
    $link $link."?ie=UTF8&amp;tag=kernconn-21";
                        
    // Parse-out the photo for each item ...
                        
    $photosource get_string_between($item->description'<img src="','"');

                        
    // If you don't want the # of the item to appear,
                        // Use a modified title ... $short_title
                        
    list ($no$short_title) = split (':'$item->title);

                        
    // Parse-out the platform for each item ...
                        
    $platform get_string_between($short_title'(',')');
                        
    $reviewsource get_string_between($item->description'Customer Review:','<br />');
                        if (
    $reviewsource == ''){
                        
    $reviewsource "Not Yet Reviewed";
                        }
                            else {
                            
    $reviewsource $reviewsource;
                            }
                            
                        
    $buynew get_string_between($item->description'"#990000">','</b>');
                        
    $buynewlink get_string_between($item->description'<a href="','">');
                        
    $buynewlink trim($buynewlink);
                        
    $buynewlink $buynewlink."?ie=UTF8&amp;tag=kernconn-21";
                        
    $used_link =get_string_between($item->description'</font> <br /><a href="','used & new');

                        
    $used_link trim($used_link);
                        
    $used_link $used_link."?ie=UTF8&amp;tag=kernconn-21";

                        
    $costs get_string_between($item->description'Buy new:</a>','</font>'); 
                        
    $old_price get_string_between($costs'<strike>','</strike>');

                            if (
    $old_price == ''){
                                
    $old_price "N/A";
                            }
                                else {
                                    
    $old_price "<s>$old_price</s>";
                                }
                            
                        
    $buynew_price get_string_between($costs'<b>','</b>'); 
                        
                        if (
    $buynew_price ==''){
                        
    $buynew_price "<i>Price Unavailable</i>";
                        }
                            else{
                            
    $buynew_price get_string_between($costs'<b>','</b>'); 
                            }
                    
                        
    $used_price get_string_between($item->description'<span class="price">','</span>'); 
                        
                        if (
    $used_price == ''){
                        
    $used_price "<b>Used and New</b><br />N/A";
                        }
                            else {
                            
    $used_price "<a href='$used_link'></a> from $used_price";
                            }

                        list (
    $no$short_title) = split (': '$item->title);

                    if(
    $count >= 0){
                        echo
    "
                        <div class='inditemheader'><a href='$link'>$short_title</a></div>
                        <div class='inditemimg'><a href='$link'>
                        <img src='$photosource' 
                        alt='$short_title' 
                        width='100' 
                        height='100' 
                        border='0'/></a>
                        </div>
                        
                        <div class='recommendsContainer_yellow'>
                        <div class='feedItems_main'><b>Platform</b><br />$platform</div>
                        <div class='feedItems_main'><b>Average Review</b><br />$reviewsource</div>
                        </div>

                        <div class='recommendsContainer_pink'>
                        <div class='feedItems_sub'><b>
                        <a href='$buynewlink'>Buy New</a></b><br />$buynew_price
                        </div>
                        
                        <div class='feedItems_sub'><b>Was</b><br /><s>$old_price</s></div>
                        <div class='feedItems_sub'>
                        <a href='$used_link'><b>Used and New</b></a> from $used_price</div>
                        </div>"
    ;  

                        }  
                        
    $count--;  
                        }
                    }
                    
                elseif (
    $feedID[$i] == 'itunes'){

    $xml=simplexml_load_file("http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/sf=143444/limit=10/explicit=true/xml?partnerId=2003&TD_PARAM=http://clkuk.tradedoubler.com/click?p=23708&amp;a=1515427&amp;url=");

                
    // How many items to display from the RSS Feed ...
                
    $count 1

                    foreach (
    $xml->entry as $item) { 
                    
    // Grabbing the NameSpace URI for "itms" and "content" ...
                    
    $ns_itms $item->children('http://phobos.apple.com/rss');
                    
    $ns_content $item->children('http://www.w3.org/2005/Atom');

                    
    // Parse-out the number of songs on an album ...
                    
    $pic str_replace("30x30-50","100x100-75",$ns_itms->image);

                        if(
    $count 0){
                            echo
    "
                            <div class='inditemheader'><a href='{$item->id}'>{$item->title}</a></div>
                            <div class='inditemimg'>
                            <a href='{$item->id}'>
                            <img src='$pic' 
                            alt='{$ns_itms->artist} - {$ns_itms->album}' 
                            border='0'/></a>
                            </div>
                            
                            <div class='recommendsContainer_yellow'>
                            <div class='feedItems_main'><b>The Album:</b>
                            {$ns_itms->collection->name}</div>                                                                                                  </div>
        
                            <div class='recommendsContainer_pink'>
                            <div class='feedItems_sub'><b>Artist:</b><br />
                            {$ns_itms->artist}</div>
                            
                            <div class='feedItems_sub'><b>Price:</b><br />
                            {$ns_itms->price}</div>
                            </div>"
    ;
                               
                               }  
                            
    $count--;  
                        }

                    }
              
              else{
              print 
    "Sorry No Information Currently Available";
              }
              

            print 
    "</div>";//recommends closed
                
            
    print "<div class='recommendsCodes'>$codes[$i]
            <div class='recommendsCodedesc'>$codesDesc[$i]</div>
            <div class='recommendsEnddate'>$expdate[$i]</div></div>"
    ;
        
            print 
    "</div>";// featured store closed
            //print "</div>";//info closed
        
    }
        
            print 
    "<div class='bottomstoreheader'>Other Stores</div>";
            print 
    "<div class='bottomstorescontainer'>";
        
                for (
    $i 3$i $rows$i++) {
                    
    $stores "<div class='storecont'>".$logos[$i]." </div>";
                    print 
    $stores;
                }

            print 
    "</div></div></div>";

    print 
    "</body>";
    ?>
    </html>
    this is the line which looks for the data on the other pages to display the correct data
    PHP Code:
        $sql "SELECT * FROM stores WHERE $cat_type  ORDER BY rating DESC"
    and on my enttest.php page i have
    PHP Code:
    <?php 
    require('pagedetails.php');
    session_start();
    $_SESSION['Cat'] = "ent";
    $_SESSION['Cat_Type'] = "( category = 'Entertainment' OR category = 'EntComp' )";
    $cat_type $_SESSION['Cat_Type'];
    however i am getting lots of unknown varible errors do i need to turn the pagedetails.php into a function or is there another way of doing this.

    cheers
    Luke

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,098
    Thanks
    297
    Thanked 12 Times in 12 Posts
    ok guys i 'think' i have it working

    is this way of doing thing a good way, what are is draw backs if any?

    cheers
    Luke

  • #3
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,098
    Thanks
    297
    Thanked 12 Times in 12 Posts
    ok one draw back i have found is that after viewing the first page and then typing in another page it loads up the same page and the previous page and only changes the data after a refresh?

    would i need to clear the session value at some point?
    cheers Luke

  • #4
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,098
    Thanks
    297
    Thanked 12 Times in 12 Posts
    ok i have solved that problem by luck more than anything else lol are there any other drawbacks to this method?

    cheers
    Luke


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •