Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-20-2010, 03:06 PM   PM User | #1
Byronwells
Regular Coder

 
Join Date: Dec 2009
Posts: 240
Thanks: 7
Thanked 0 Times in 0 Posts
Byronwells can only hope to improve
How Do I Get The Date To Reapper In This New Query?

Alright guys

Please take a look at this page http://www.digitalresellersvault.com/member/newest.php

I have writen a query that allows me to display the latest category that I have had to the membership site on this page

Code:
<?php
include_once ("header.php");

	$query  = "SELECT cat_name FROM ".$prefix."category ORDER BY id DESC LIMIT 1";
	$result = mysql_query($query);

  while ($row = mysql_fetch_array($result, MYSQL_NUM))
   { 
   $cat = $row[0];
   }

	$link = $cat;
	$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];
	
	$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=$category&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)";}
		
		
		$product_name='<a href="prods.php?pid='.$id.'">'.$product_name.'</a>';
		

		if($subscription_active == "1")
			{
			$salesprice = $amount3." every ".$period3_value." ".$interval;
			}
		else
			{
			$salesprice = $price;
			}	
		$prod_image='<a href="prods.php?pid='.$id.'"><img src="images/'.$imageurl.'"></a>';	
		$download_link='<a href="http://www.digitalresellersvault.com/go/downloads/'.$download_link.'"><img border="0" src="http://www.digitalresellersvault.com/template/images/downloadbutton.jpg" width="104" height="16"></a>';

		$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");
?>
However now no date appears in the product section.. If you have look at any of the categories link, you will see what I mean..

This was the orignal 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("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 *,DATE_FORMAT(product_date, '%m-%d-%Y') as date 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>';
	$product_name='<a href="prods.php?pid='.$id.'">'.$product_name.'</a>';			
	$prod_image='<a href="prods.php?pid='.$id.'"><img src="images/'.$imageurl.'"></a>';		
	$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=$category&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 *,(SELECT
DATE_FORMAT(product_date, '%b/%d/%Y')) as formatteddate 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)";}
		
		
		$product_name='<a href="prods.php?pid='.$id.'">'.$product_name.'</a>';
		

		if($subscription_active == "1")
			{
			$salesprice = $amount3." every ".$period3_value." ".$interval;
			}
		else
			{
			$salesprice = $price;
			}	
		$prod_image='<a href="prods.php?pid='.$id.'"><img src="images/'.$imageurl.'"></a>';	
		$download_link='<a href="http://www.digitalresellersvault.com/go/downloads/'.$download_link.'"><img border="0" src="http://www.digitalresellersvault.com/template/images/downloadbutton.jpg" width="104" height="16"></a>';

		$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");
?>
Byronwells is offline   Reply With Quote
Old 03-21-2010, 02:30 AM   PM User | #2
Len Whistler
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
Len Whistler is on a distinguished road
I'm not sure of the exact line(s) that are missing in your first code sample but I did a browser Find query for "date" and date shows up only once in your first example and seven times in the original working code sample.




------------------
__________________
Leonard Whistler
Len Whistler is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 07:23 PM.


Advertisement
Log in to turn off these ads.