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 9 of 9
  1. #1
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,088
    Thanks
    296
    Thanked 12 Times in 12 Posts

    Arrow passing a value to another page???

    Hi All,

    Ok im gonna try and describ this the best i can

    i have several feeds of which the first 3 items are inserted into my db i then use php to pull out the specific items and place them in the correct divs which is fine

    i then have and image inderneath the item header with the alt and title tag set to the title of the item in the database. (still following?)

    i have also set the image to link to another php page results.php which it does

    here is the problem...
    i am unable to pass the item title to the other php page, can i use the image title as a varible?

    is it possible

    my php code is
    PHP Code:
    <?php    
        
        $category_list 
    = array("DVD""CD""Video Games""Blu-Ray""Books");
        
    $subcategory_list = array("Bestsellers","New Releases","Gifted");
        
        
    $cat_count 0;
        
        foreach (
    $category_list as $category){
        
        print 
    "<div class='catsections'>
        <div class='catheader'>
        
        <div class='category_name'>
        <h1>$category_list[$cat_count]</h1>
        </div>
        
        </div>
        
        <div class='cattop'>
        
            <div class='cattop_header'>
            Kernow Connect Pick Of The Week
            </div>
            
            <div class='cattop_item'></div>
            <div class='cattop_desc'></div>
        </div>"
    ;
        
        
    $sub_count 0;
        
        foreach(
    $subcategory_list as $subcategory){
        
        print 
    "<div class='top3'>
            
        <div class='subcat_header'>
        $subcategory_list[$sub_count]
        </div>"
    ;
            
        
    $itemdata "SELECT * 
        FROM category_data 
        WHERE page_category = 'Entertainment' 
        AND cat_id = '$category_list[$cat_count]' 
        AND subcat_id = '$subcategory_list[$sub_count]'"

                    
        
    $item_query=mysql_query($itemdata);
        
    $num_rows mysql_num_rows($item_query);
            
            if (
    $num_rows == 0){
                echo 
    "No Results Please Go Back And Try Again";
            }
              else {
                   while (
    $row mysql_fetch_array($item_query)){
                
    $short_title preg_replace("/#\d: |\s*\(.*\)|\s*\[.*\]/U"""$row['title']);
                
    $short_title=htmlentities($short_title);
                print 
    '<div class="item">
                
                <div class="itemIMG">
                <img src="'
    .$row['image'].'" 
                alt="'
    .$short_title.'" 
                title="'
    .$short_title.'" 
                height="100" />
                </div>
                
                <div class="itemTitle">'
    .$short_title.'</div>
                <div class="itemButton">
                <a href="http://www.kernow-connect.com/results.php">
                <img src="images/compare.gif"  
                alt="'
    .$short_title.'"  
                title="'
    .$short_title.'" border="0" /></a>
                </div>            
                </div>'
    ;
                        
                 }
             print
    "</div>";
             }  
                  
    $sub_count ++;
            }
            print 
    "</div>";
            
            
            
        
            
    $cat_count ++;
            
        }
        
    ?>
    any help would be greatly appreciated
    thanks for your time
    Luke
    Last edited by LJackson; 05-08-2009 at 12:28 AM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    Change your link like
    Code:
    <a href="http://www.kernow-connect.com/results.php?title='.$short_title.'">
                <img src="images/compare.gif"  
                alt="'.$short_title.'"  
                title="'.$short_title.'" border="0" /></a>
    and then use $_GET['title'] in your results.php page.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    LJackson (05-07-2009)

  • #3
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,088
    Thanks
    296
    Thanked 12 Times in 12 Posts


    OMG Thank You!!!!!

    I didn't think that would work because i was unsure how it would know what $short_title should be, but looking back at my code its obvious it would work as the loop would insert each item at a time with the correct link info attached to that item.... wow i thought this was going to take ages lol

    so the same would work with sessions then???

    thank you!!!!!!!!!!!!!!!!!!!!!!
    Luke

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    so the same would work with sessions then???
    Not in this case. Since you are generating a lot of links by your loop, it's not so easy to store and retrieve using sessions. If you are really worried about passing the entire title in the url, you may just send the table id (of that row) in the url and then query again in the next page to get that particular title from the table.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,088
    Thanks
    296
    Thanked 12 Times in 12 Posts
    mmm ok, im not worried about passing the entire varible in the url it just looks a bit messy if i have a long title thats all.

    i think i'll leave it as it is then

    thank you
    Luke

  • #6
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I suggest you use htmlentities on your $_GET to prevent XSS injection.
    Code:
    htmlentities($_GET['title']);
    This way if a user tried to enter html into the title= part it would convert it to entities rather than html.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    LJackson (05-07-2009)

  • #7
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,088
    Thanks
    296
    Thanked 12 Times in 12 Posts
    hi mate, i have used as you have suggested as above which is fine but further along in the script i call the varible as so

    Code:
        <div class="searchbar">
          <input name="searchbox" 
        	type="text" 
        	value="<?php print $inputtext ?>" 
        	size="75" 
        	onfocus="clearText(this)" 
        	onblur="clearText(this)"/>
        </div>
    but it displays a \' before the varible value, how do i remove this?

    thanks
    Luke

  • #8
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    It's worth to read GPC Stripping Tutorial
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    LJackson (05-09-2009)

  • #9
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Fou-lu's tutorial might be overkill if you aren't using a lot of gets or posts. If you aren't then just use stripslashes($inputtext)
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    LJackson (05-09-2009)


  •  

    Posting Permissions

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