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

    How Do I Get The Date To BE Displayed In The Right Order??

    Alright guys

    Please take a look at this page

    http://www.digitalresellersvault.com...ategory=Videos

    The products are being display in the wrong order.. I would like the products to be displayed in date order.. With the newest date showing first and so on

    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("http://www.digitalresellersvault.com/template/template.php");
    	$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];
    	$licence = $r[licence];
    	$product_date = $r[product_date];
    	$salespage_link='<a href="prods.php?pid='.$id.'"><img border="0" src="http://www.digitalresellersvault.com/template/images/moreinfobutton.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/template/template.php");
    	$Content = join("", $GetFile);
    	$categories=$common->categories($db);
    	$content=str_replace("{categories}",$categories,$content);	
    	$theselect=$common->category_select($db, 'select');
     $Content = str_replace("{{category_select}}", $theselect, $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&category=$link&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 product_date 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/template/images/moreinfobutton.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");
    ?>

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    at this line:

    PHP Code:
    ("select * from ".$prefix."products $cond order by product_date DESC limit $start, $records"); 
    you have:

    order by product_date DESC


    thats how the list is currently ordered, if you want to reverse the order then switch if to ASC, like:

    order by product_date ASC

  • #3
    Regular Coder
    Join Date
    Dec 2009
    Posts
    243
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by angst View Post
    at this line:

    PHP Code:
    ("select * from ".$prefix."products $cond order by product_date DESC limit $start, $records"); 
    you have:

    order by product_date DESC


    thats how the list is currently ordered, if you want to reverse the order then switch if to ASC, like:

    order by product_date ASC
    Alrihgt Angst..

    I can do that but it wont really work as the way I want it... Lets say for example I add 3 products with the following dates

    product 1 with date 12/02/2009
    product 2 with date 01/12/2010
    product 3 with date 12/03/2009

    In that same order... Product 2 needs to be the lastes one showing, and then product 1 , and 3 needs to go in the right order.. Just like you can do a wordpress blog...

  • #4
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    right, so then your original code should work, using DESC.

  • #5
    Regular Coder
    Join Date
    Dec 2009
    Posts
    243
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by angst View Post
    right, so then your original code should work, using DESC.
    Well that is what I am already using and it is not in date order

  • #6
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    well if that doesn't work then I would assume that something is wrong with the dates that are stored in your db. what field type are you using to store the dates?


  •  

    Posting Permissions

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