Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 25th Jan 2010, 12:43 AM   #1
Advanced Warrior
 
Join Date: 2008
Posts: 715
Thanks: 33
Thanked 6 Times in 5 Posts
Default
A Question For Php Coders.. I just need some clafication please.....
Share on: 
fb share twitter share gplus share more share

Alright PHP coders

I have this query for you that I just need a little bit of clarification on please..

If you kindly take a look at this page... Untitled Document you will notice that all the categories are display on the left hand side.. And when you click on one it will change and so on, to what ever you look at..

The code for that page is as follows...
<?php
include_once ("header.php");
$cat = $_GET["cat"];
$link = $_GET["category"];
$search = $_GET["search"];
$cat_title = str_replace("_"," ",$link);
if($cat != "t")
{
$GetFile = file("http://www.digitalresellersvault.com...e/template.php");
$Content = join("", $GetFile);
$categories=$common->categories($db);
$content=str_replace("{categories}",$categories,$c ontent);
$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.'"><img border="0" src="http://www.digitalresellersvault.com...infobutton.jpg" width="104" height="16"></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("http://www.digitalresellersvault.com...e/template.php");
$Content = join("", $GetFile);
$categories=$common->categories($db);
$content=str_replace("{categories}",$categories,$c ontent);
$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&category=$link&searc h_txt=$search_txt&";
if($page=="")
{
$page=1;
}
$start=($page-1)*$records;
$Content=$common->print_page_break3($db,$Content,$count,$records,$l inks,$page);
########## pagination ###########
$ChangeColor = 1;
$ToReplace = "";
$GetProduct = $db->get_rsltset("select * from ".$prefix."products $cond order by id DESC 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"width="140" height="140">';
$salespage_link='<a href="prods.php?pid='.$id.'"><img border="0" src="http://www.digitalresellersvault.com...infobutton.jpg" width="104" height="16"></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");
?>

My question/query is as follows..

I would like to get the newest product link under the navigational section on the left hand side to show all of the products under the newest categories that we have added..

This will always automatically update when you add a new category to the membership script..

My question.. Do I need to create a separate file lets say newestproduct.php and then use the above code in that page.. to get part to work?

Or can I do it from one marketplace.php file? If so I guess I need to modified the above code? Or do I add the code at the bottom...

I am hoping that I have made sense
Byron_Wells is offline  
Unread 25th Jan 2010, 07:51 AM   #2
Customer Tools
War Room Member
 
Join Date: 2009
Location: Texas
Posts: 101
Thanks: 5
Thanked 5 Times in 5 Posts
Default
Re: A Question For Php Coders.. I just need some clafication please.....
Share on: 
fb share twitter share gplus share more share

Post this question at stackoverflow.com you're more likely to get an answer there. But If I understand you correctly it should be fairly easy to do but would be easier for me to do something like that with the database structure. I'm sure some of the better php guys wouldn't need it.
customertools is offline  
Unread 27th Jan 2010, 08:35 AM   #3
HyperActive Warrior
War Room Member
 
Join Date: 2008
Location: New York
Posts: 156
Thanks: 0
Thanked 24 Times in 20 Posts
Default
Re: A Question For Php Coders.. I just need some clafication please.....
Share on: 
fb share twitter share gplus share more share

Personally, I don't think that a "newest products" link should be showing products from the newest category. What if you add new products to a category that you've had for a long time? Even though the product is new, it won't be listed in "newest products" because the category is not new. Does that make sense?

So what I would do is have the "newest products" link go to a script where you do something like
Code:
select * from products_table order by date_added desc limit 0, 10
That will display the 10 most recently added products (assuming you're using MySQL).

If you really, really want to do it the way you said (products from newest category), then your query would be something like the following:
Code:
select * from products_table pt where pt.category_id in (select ct.category_id from category_table ct order by date_added desc limit 0, 1)
That will give you all products from the most recently added category

Hope that helps

martinkeens is offline  
Unread 27th Jan 2010, 04:24 PM   #4
Advanced Warrior
 
Join Date: 2008
Posts: 715
Thanks: 33
Thanked 6 Times in 5 Posts
Default
Re: A Question For Php Coders.. I just need some clafication please.....
Share on: 
fb share twitter share gplus share more share

Originally Posted by martinkeens View Post

Personally, I don't think that a "newest products" link should be showing products from the newest category. What if you add new products to a category that you've had for a long time? Even though the product is new, it won't be listed in "newest products" because the category is not new. Does that make sense?

So what I would do is have the "newest products" link go to a script where you do something like
Code:
select * from products_table order by date_added desc limit 0, 10
That will display the 10 most recently added products (assuming you're using MySQL).

If you really, really want to do it the way you said (products from newest category), then your query would be something like the following:
Code:
select * from products_table pt where pt.category_id in (select ct.category_id from category_table ct order by date_added desc limit 0, 1)
That will give you all products from the most recently added category

Hope that helps
What I was thinking.. Because I will adding products on a daily basis, linking them to the categories section, via month of the year, i,e jan 2010, feb 2010, and so on
Byron_Wells is offline  
Closed Thread


Bookmarks

Tags
clafication, coders, php, question


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 08:26 PM.