Slow and No

Here it is in all of its glory:

Code:
<?php
#	Function for navigation build ::
function buildNavigation($pageNum_Recordset1,$totalPages_Recordset1,$prev_Recordset1,$next_Recordset1,$separator=" | ",$max_links=10, $show_page=true)
{
                GLOBAL $maxRows_Recordset1,$totalRows_Recordset1;
	$pagesArray = ""; $firstArray = ""; $lastArray = "";
	if($max_links<2)$max_links=2;
	if($pageNum_Recordset1<=$totalPages_Recordset1 && $pageNum_Recordset1>=0)
	{
		if ($pageNum_Recordset1 > ceil($max_links/2))
		{
			$fgp = $pageNum_Recordset1 - ceil($max_links/2) > 0 ? $pageNum_Recordset1 - ceil($max_links/2) : 1;
			$egp = $pageNum_Recordset1 + ceil($max_links/2);
			if ($egp >= $totalPages_Recordset1)
			{
				$egp = $totalPages_Recordset1+1;
				$fgp = $totalPages_Recordset1 - ($max_links-1) > 0 ? $totalPages_Recordset1  - ($max_links-1) : 1;
			}
		}
		else {
			$fgp = 0;
			$egp = $totalPages_Recordset1 >= $max_links ? $max_links : $totalPages_Recordset1+1;
		}
		if($totalPages_Recordset1 >= 1) {
			#	------------------------
			#	Searching for $_GET vars
			#	------------------------
			$_get_vars = '';			
			if(!empty($_GET) || !empty($HTTP_GET_VARS)){
				$_GET = empty($_GET) ? $HTTP_GET_VARS : $_GET;
				foreach ($_GET as $_get_name => $_get_value) {
					if ($_get_name != "pageNum_Recordset1") {
						$_get_vars .= "&$_get_name=$_get_value";
					}
				}
			}
			$successivo = $pageNum_Recordset1+1;
			$precedente = $pageNum_Recordset1-1;
			$firstArray = ($pageNum_Recordset1 > 0) ? "<a href=\"$_SERVER[PHP_SELF]?pageNum_Recordset1=$precedente$_get_vars\">$prev_Recordset1</a>" :  "$prev_Recordset1";
			# ----------------------
			# page numbers
			# ----------------------
			for($a = $fgp+1; $a <= $egp; $a++){
				$theNext = $a-1;
				if($show_page)
				{
					$textLink = $a;
				} else {
					$min_l = (($a-1)*$maxRows_Recordset1) + 1;
					$max_l = ($a*$maxRows_Recordset1 >= $totalRows_Recordset1) ? $totalRows_Recordset1 : ($a*$maxRows_Recordset1);
					$textLink = "$min_l - $max_l";
				}
				$_ss_k = floor($theNext/26);
				if ($theNext != $pageNum_Recordset1)
				{
					$pagesArray .= "<a href=\"$_SERVER[PHP_SELF]?pageNum_Recordset1=$theNext$_get_vars\">";
					$pagesArray .= "$textLink</a>" . ($theNext < $egp-1 ? $separator : "");
				} else {
					$pagesArray .= "$textLink"  . ($theNext < $egp-1 ? $separator : "");
				}
			}
			$theNext = $pageNum_Recordset1+1;
			$offset_end = $totalPages_Recordset1;
			$lastArray = ($pageNum_Recordset1 < $totalPages_Recordset1) ? "<a href=\"$_SERVER[PHP_SELF]?pageNum_Recordset1=$successivo$_get_vars\">$next_Recordset1</a>" : "$next_Recordset1";
		}
	}
	return array($firstArray,$pagesArray,$lastArray);
}
 require_once('../Connections/myConnection.php'); 

$tfm_orderby =(!isset($_GET["tfm_orderby"]))?"make":$_GET["tfm_orderby"];
$tfm_order =(!isset($_GET["tfm_order"]))?"ASC":$_GET["tfm_order"];
$sql_orderby = " " .$tfm_orderby." ".$tfm_order;

	$thisPage=$_SERVER['PHP_SELF'];
	
		$SSAdv_colors1 = array("#ffffff","#d5dee3");
		$SSAdv_k1 = 0;
		$SSAdv_m1 = 0;
		$SSAdv_change_every1 = 1;
		
if ((!$year) && (!$make) && (!$model)) {
		$maxRows_Recordset1 = 20;
		} else {
		$maxRows_Recordset1 = 20;
		}
		$pageNum_Recordset1 = 0;
		if (isset($_GET['pageNum_Recordset1'])) {
		  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
		}
		$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
		
		$sqlorderby_Recordset1 = "make";
		if (isset($sql_orderby)) {
		  $sqlorderby_Recordset1 = (get_magic_quotes_gpc()) ? $sql_orderby : addslashes($sql_orderby);
		}
		mysql_select_db($database_myConnection, $myConnection);
		if ((!$year) && (!$make) && (!$model) && (!$certified)) {
		
/*Alexei's code here		
$query_Recordset1 = "SELECT * FROM used_vehicle ";
 if(isset($_GET['year'])){
  $where_set=true;
 $query_Recordset1.="WHERE year='".$_GET['year']."'";
}
 if(isset($_GET['make'])){
   if($where_set=true){
     $query_Recordset1.= " AND ";
   }else{
      $query_Recordset1.= " WHERE ";
  }
   $query_Recordset1.= "make = '".$_GET['make']."'";
 }	
// End Alexei's code*/
		
		$query_Recordset1 = sprintf("SELECT * FROM used_vehicle ORDER BY %s", $sqlorderby_Recordset1);
		} else if ((!$make) && (!$model) && (!$certified)) {
		$query_Recordset1 = sprintf("SELECT * FROM used_vehicle WHERE year = '$year' ORDER BY make", $sqlorderby_Recordset1);
		} else if (($year != "") && ($model != "") && (!$certified)) {
		$query_Recordset1 = sprintf("SELECT * FROM used_vehicle WHERE year = '$year' AND WHERE make = '$make' ORDER BY make", $sqlorderby_Recordset1);
		} else if ((!$year) && (!$make) && (!$certified)) {
		$query_Recordset1 = sprintf("SELECT * FROM used_vehicle WHERE year = '$year' OR make = '$make' OR model = '$model' ORDER BY make", $sqlorderby_Recordset1);
		} else if ((!$year) && (!$make) && (!$model)) {
		$query_Recordset1 = sprintf("SELECT * FROM used_vehicle WHERE certified = '1' ORDER BY make,model,web_price", $sqlorderby_Recordset1);
		
		} 
		$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
		$Recordset1 = mysql_query($query_limit_Recordset1, $myConnection) or die(mysql_error());
		$row_Recordset1 = mysql_fetch_assoc($Recordset1);
		
		if (isset($_GET['totalRows_Recordset1'])) {
		  $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
		} else {
		  $all_Recordset1 = mysql_query($query_Recordset1);
		  $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
		}
		$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
# 
# $query_Recordset1 = "SELECT * FROM used_vechicles ";
#
# if(isset($_GET['year'])){
#  $where_set=true;
#  $query_Recordset1.="WHERE year='".$_GET['year']."'";
# }
# if(isset($_GET['make']){
#   if($where_set=true){
#      $query_Recordset1.= " AND ";
#   }else{
#      $query_Recordset1.= " WHERE ";
#   }
#   $query_Recordset1.= "make = '".$_GET['make']."'";
# }
#
	
	
	
	
	mysql_select_db($database_myConnection, $myConnection);
	$query_RecordsetYear = "SELECT DISTINCT year FROM used_vehicle ORDER BY year";
	$RecordsetYear = mysql_query($query_RecordsetYear, $myConnection) or die(mysql_error());
	$row_RecordsetYear = mysql_fetch_assoc($RecordsetYear);
	$totalRows_RecordsetYear = mysql_num_rows($RecordsetYear);
	
	mysql_select_db($database_myConnection, $myConnection);
	$query_RecordsetMake = "SELECT DISTINCT make FROM used_vehicle WHERE year = '$year' OR model='$model' ORDER BY make";
	$RecordsetMake = mysql_query($query_RecordsetMake, $myConnection) or die(mysql_error());
	$row_RecordsetMake = mysql_fetch_assoc($RecordsetMake);
	$totalRows_RecordsetMake = mysql_num_rows($RecordsetMake);
	
	mysql_select_db($database_myConnection, $myConnection);
	$query_Recordsetmodel = "SELECT DISTINCT model FROM used_vehicle WHERE year='$year' OR make='$make' ORDER BY model";
	$Recordsetmodel = mysql_query($query_Recordsetmodel, $myConnection) or die(mysql_error());
	$row_Recordsetmodel = mysql_fetch_assoc($Recordsetmodel);
	$totalRows_Recordsetmodel = mysql_num_rows($Recordsetmodel);
	
	mysql_select_db($database_myConnection, $myConnection);
	$query_RecordsetCert = "SELECT DISTINCT certified FROM used_vehicle WHERE certified = '1'";
	$RecordsetCert = mysql_query($query_RecordsetCert, $myConnection) or die(mysql_error());
	$row_RecordsetCert = mysql_fetch_assoc($RecordsetCert);
	$totalRows_RecordsetCert = mysql_num_rows($RecordsetCert);

//sort column headers for Recordset1
$tfm_saveParams = explode(",","");
$tfm_keepParams = "";
if($tfm_order == "ASC") {
	$tfm_order = "DESC";
}else{
	$tfm_order = "ASC";
};
while (list($key,$val) = each($tfm_saveParams)) {
	if(isset($_GET[$val]))$tfm_keepParams .= ($val)."=".urlencode($HTTP_GET_VARS[$val])."&";	
	if(isset($_POST[$val]))$tfm_keepParams .= ($val)."=".urlencode($HTTP_POST_VARS[$val])."&";
}
$tfm_orderbyURL = $HTTP_SERVER_VARS["PHP_SELF"]."?".$tfm_keepParams."tfm_order=".$tfm_order."&tfm_orderby=";
?>
 
I tried entering your code but still got the error message, only this time it comes up after only selecting the year. With the code I wrote I could at least select the year and then it would give me all of my makes available for that year but once I select the make it wil give me the sql syntax error near limit. I haven't had the oppurtunity to try it in a seperate file from all the other code but hopefully will get a chace sometime today on that.
 
Back
Top