...

View Full Version : I need To Add THis Code, But how/where?



Byronwells
01-15-2010, 06:48 PM
Alright Guys

I am using a membership script, called simplememberpro.. Please see here http://www.ultimateresalegiveaway.com/marketplace.php?cat=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



<?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");
?>

Len Whistler
01-15-2010, 07:39 PM
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.


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.



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

Byronwells
01-15-2010, 08:06 PM
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.


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.



########## 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.. :)

Len Whistler
01-15-2010, 08:14 PM
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.



----------------------

Byronwells
01-15-2010, 08:27 PM
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?

Len Whistler
01-15-2010, 10:21 PM
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:


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.



----

Byronwells
01-16-2010, 12:19 AM
Alright guys

I have cracked the code..

Replace this code:


$links="marketplace.php?cat=t&search_txt=$search_txt&";


To this one:


$links="marketplace.php?cat=t&category=$link&search_txt=$search_txt&";

Len Whistler
01-16-2010, 12:38 AM
$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.


-------

Byronwells
01-16-2010, 12:50 AM
$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?

Len Whistler
01-16-2010, 06:10 AM
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:


$cat = $_GET["cat"];
$link = $_GET["category"];

And it produces this URL:
marketplace.php?cat=t&category=1


It should be more like:


$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.

-------------



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum