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 10 of 10
  1. #1
    Regular Coder
    Join Date
    Dec 2009
    Posts
    240
    Thanks
    7
    Thanked 0 Times in 0 Posts

    I need To Add THis Code, But how/where?

    Alright Guys

    I am using a membership script, called simplememberpro.. Please see here http://www.ultimateresalegiveaway.co...t=t&category=1

    For some reason when you click on page 2 on the same category.. You get a new page, but no categories are displayed on it..

    I have spoken to the owener of the script and he has said the following...

    "I can see what the error is, the &category= tag is missing from the code in marketplace.php."

    He will try and fix it himself over the weekend.. Or it will get done on Monday.. It cant really waiti that long

    Here is the full marketplace.php code

    Code:
    <?php
    include_once ("header.php");
    $cat = $_GET["cat"];
    $link = $_GET["category"];
    $search = $_GET["search"];
    $cat_title = str_replace("_"," ",$link);
    
    if($cat != "t")
    	{
    	$GetFile = file("html/categories.html");
    	$Content = join("", $GetFile);
    	$categories=$common->categories($db);
    	$content=str_replace("{categories}",$categories,$content);	
    	$Pat = "/<{Begin}>(.*?)<{End}>/s";
    	preg_match($Pat,$Content,$Output);
    	$SelectedContent = $Output[1];
    	$q = "select * from ".$prefix."products where show_product = '1' ORDER BY Rand() LIMIT 1";
    	$r = $db->get_a_line($q);
    	$id = $r[id];
    	$imageurl = $r[imageurl];
    	$prod_description = $r[prod_description];
    	$salesprice = $r[price];
    	$product_name = $r[product_name];
    	$salespage_link='<a href="prods.php?pid='.$id.'">Click Here For More Information</a>';
    	
    			
    	$prod_image ='<img src="images/'.$imageurl.'" border="0">';
    	
    	$Content = preg_replace($Pat,$ToReplace,$Content);
    	$Content = preg_replace("/{{(.*?)}}/e", "$$1", $Content);
    	echo $Content;
    	include_once ("footer.php");		
    	exit();		
    	}
    
    
    elseif($cat == "t")
    	{
    	$search = $_GET["search"];
    	$link = $_GET["category"];
    	$cat_title = str_replace("_"," ",$link);
    	$GetFile = file("html/marketplace.html");
    	$Content = join("", $GetFile);
    	$categories=$common->categories($db);
    	$content=str_replace("{categories}",$categories,$content);	
    	$Pat = "/<{Begin}>(.*?)<{End}>/s";
    	preg_match($Pat,$Content,$Output);
    	$SelectedContent = $Output[1];
    
    	if($search_txt != "")
    		{
    		$cond	= "where product_name like '%".$search_txt."%' && show_product = '1'";		
    		}
    	else
    		{
    		$cond	= "where category = '$cat_title' && show_product = '1'";
    		}
    
    	########## pagination ###########
    	$q = "select count(*) as cnt from ".$prefix."products $cond";
    	$r = $db->get_a_line($q);
    	$count = $r[cnt];
    	if($count == "0")
    		{
    		$warning = "No Results Found";
    		}
    	$records=10;
    	$links="marketplace.php?cat=t&search_txt=$search_txt&";
    	if($page=="")
    		{
    		$page=1;
    		}
    	$start=($page-1)*$records;
    	$Content=$common->print_page_break3($db,$Content,$count,$records,$links,$page);
    	########## pagination ###########
    
    	$ChangeColor = 1;
    	$ToReplace = "";
    	$GetProduct = $db->get_rsltset("select * from ".$prefix."products $cond order by id asc limit $start, $records");
    	for($i = 0; $i < count($GetProduct); $i++)
    		{
    		$bgcolor = "#FFFFFF";
    		@extract($GetProduct[$i]);
    		if($period3_interval == "D"){$interval = "Day(s)";}
    		if($period3_interval == "W"){$interval = "Week(s)";}
    		if($period3_interval == "M"){$interval = "Month(s)";}
    		if($period3_interval == "Y"){$interval = "Year(s)";}
    
    		if($subscription_active == "1")
    			{
    			$salesprice = $amount3." every ".$period3_value." ".$interval;
    			}
    		else
    			{
    			$salesprice = $price;
    			}	
    		$prod_image ='<img src="images/'.$imageurl.'" border="0">';
    		$salespage_link='<a href="prods.php?pid='.$id.'">Click Here For More Information</a>';
    		$ToReplace .= preg_replace($Ptn,"$$1",$SelectedContent);
    		}
    	}	
    		
    $Content = preg_replace($Pat,$ToReplace,$Content);
    $Content = preg_replace("/{{(.*?)}}/e", "$$1", $Content);
    echo $Content;
    include_once ("footer.php");
    ?>

  • #2
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    What is the purpose of $cat_title? The value of $link is an integer such as 1 or 2. Also $link should be $page to avoid confusion because the value is the page number for your pagination.

    Code:
    include_once ("header.php");
    $cat = $_GET["cat"];
    $link = $_GET["category"];
    $search = $_GET["search"];
    $cat_title = str_replace("_"," ",$link);
    

    Replace the code in red with the code in green and see if it works. Make sure you have more than 10 records in database.
    Code:
    ########## pagination ###########
    	$q = "select count(*) as cnt from ".$prefix."products $cond";
    	$r = $db->get_a_line($q);
    	$count = $r[cnt];
    	if($count == "0")
    		{
    		$warning = "No Results Found";
    		}
    	$records=10;
    	$links="marketplace.php?cat=t&search_txt=$search_txt&";
    
    	if($page=="")
    		{
    		$page=1;
    		}
    	$start=($page-1)*$records;
    
    if(!isset($_GET['catagory'])){
        $page = 1;
    } else {
        $page = $_GET['catagory'];
    }
    $start=($page-1)*$records; 
    
    
    
    	$Content=$common->print_page_break3($db,$Content,$count,$records,$links,$page);
    	########## pagination ###########
    Last edited by Len Whistler; 01-15-2010 at 07:51 PM.
    Leonard Whistler

  • #3
    Regular Coder
    Join Date
    Dec 2009
    Posts
    240
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Len Whistler View Post
    What is the purpose of $cat_title? The value of $link is an integer such as 1 or 2. Also $link should be $page to avoid confusion because the value is the page number for your pagination.

    Code:
    include_once ("header.php");
    $cat = $_GET["cat"];
    $link = $_GET["category"];
    $search = $_GET["search"];
    $cat_title = str_replace("_"," ",$link);
    

    Replace the code in red with the code in green and see if it works. Make sure you have more than 10 records in database.
    Code:
    ########## pagination ###########
    	$q = "select count(*) as cnt from ".$prefix."products $cond";
    	$r = $db->get_a_line($q);
    	$count = $r[cnt];
    	if($count == "0")
    		{
    		$warning = "No Results Found";
    		}
    	$records=10;
    	$links="marketplace.php?cat=t&search_txt=$search_txt&";
    
    	if($page=="")
    		{
    		$page=1;
    		}
    	$start=($page-1)*$records;
    
    if(!isset($_GET['catagory'])){
        $page = 1;
    } else {
        $page = $_GET['catagory'];
    }
    $start=($page-1)*$records; 
    
    
    
    	$Content=$common->print_page_break3($db,$Content,$count,$records,$links,$page);
    	########## pagination ###########
    I believe that the $cat_title = str_replace("_"," ",$link); part is revalent to displays the titles of each product in a certain place on the page...

    I have changed the part from red to the text in green but nothing is happening as yet..

  • #4
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Quote Originally Posted by Byronwells View Post
    I have changed the part from red to the text in green but nothing is happening as yet..

    echo out $page anywhere below the code in green to check it's value. You should be getting 1 on page 1 and 2 on page 2.



    ----------------------
    Leonard Whistler

  • #5
    Regular Coder
    Join Date
    Dec 2009
    Posts
    240
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Len Whistler View Post
    echo out $page anywhere below the code in green to check it's value. You should be getting 1 on page 1 and 2 on page 2.



    ----------------------
    Sorry Len

    To sound dumb but what do you mean when you say echo out $page?

  • #6
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Quote Originally Posted by Byronwells View Post
    Sorry Len

    To sound dumb but what do you mean when you say echo out $page?
    This is part of error checking, to make sure the values are correct. Example:

    PHP Code:
    include_once ("header.php");
    $cat $_GET["cat"];
    $link $_GET["category"];
    $search $_GET["search"];
    $cat_title str_replace("_"," ",$link);


    echo 
    "Cat $cat<br>";
    echo 
    "Link $link<br>";
    echo 
    "Search $search<br>";
    echo 
    "Cat Title $cat_title<br>";

    if(!isset(
    $_GET['catagory'])){
        
    $page 1;
    } else {
        
    $page $_GET['catagory'];
    }
    $start=($page-1)*$records

    echo 
    "Page $page<br>";
    echo 
    "Start $start<br>"
    If the values echoed are correct then you can proceed down the script until you have it working. Then delete all error checking echoes.



    ----
    Last edited by Len Whistler; 01-15-2010 at 10:24 PM.
    Leonard Whistler

  • #7
    Regular Coder
    Join Date
    Dec 2009
    Posts
    240
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Alright guys

    I have cracked the code..

    Replace this code:
    Code:
    $links="marketplace.php?cat=t&search_txt=$search_txt&";
    To this one:
    Code:
    $links="marketplace.php?cat=t&category=$link&search_txt=$search_txt&";

  • #8
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Code:
    $links="marketplace.php?cat=t&category=$link&search_txt=$search_txt&";

    In the future I would give variables descriptive names to help with coding and debugging. Example:

    cat=t What does t stand for? How about trains, cars, boats, planes instead, a full word looks better in the URL.

    category= Category is actual pages and should be changed to page= , plus it can be easily confused with cat, which sometimes is short hand for category.


    -------
    Leonard Whistler

  • #9
    Regular Coder
    Join Date
    Dec 2009
    Posts
    240
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Len Whistler View Post
    Code:
    $links="marketplace.php?cat=t&category=$link&search_txt=$search_txt&";

    In the future I would give variables descriptive names to help with coding and debugging. Example:

    cat=t What does t stand for? How about trains, cars, boats, planes instead, a full word looks better in the URL.

    category= Category is actual pages and should be changed to page= , plus it can be easily confused with cat, which sometimes is short hand for category.


    -------
    I understand what you are saying.. But because I am using a membership script that runs off a database.. Wouldnt I have to change the database structure to begin with??

    Or is there some other way that I can get full word looks better in the URL to appear please?

  • #10
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Quote Originally Posted by Byronwells View Post
    I understand what you are saying.. But because I am using a membership script that runs off a database.. Wouldnt I have to change the database structure to begin with??

    Or is there some other way that I can get full word looks better in the URL to appear please?

    It can be all taken care of in the coding of the page. Below is what you presently have:

    Code:
    $cat = $_GET["cat"];
    $link = $_GET["category"];
    And it produces this URL:
    marketplace.php?cat=t&category=1


    It should be more like:

    Code:
    $category = $_GET["category"]; // or cat for short
    $page = $_GET["page"];
    marketplace.php?category=books&page=1



    When it comes to the database the category column should contain descriptive names such as: books, cars, boats, etc. Not entries like t.

    -------------
    Leonard Whistler


  •  

    Posting Permissions

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