Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,158,164 members, 7,835,900 topics. Date: Tuesday, 21 May 2024 at 05:09 PM

Php Assistance - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Php Assistance (647 Views)

Is Anyone Using The Opencart Ecommerce Solution? Your Assistance Is Needed (2) (3) (4)

(1) (Reply) (Go Down)

Php Assistance by jeshurun07: 3:34pm On Jul 21, 2010
hello guys,
need some help with my php codes
i intend to dynamically generate a search query which would depend on the selections made by the search visitor
so far this is how far i have gone.
I have tried the SQL string in phpmyadmin and it works however when i insert my string into the dbase. it generates an SQL error. Can some one pls tell me where i am getting it wrong?

include("database_connector"wink;
$searchTerm=NULL;
$var =NULL;
if(isset($_GET)){
#Get the property type
if(!empty($_GET['proptype'])){
$propType=$_GET['proptype'];
$prop='propType=';
$prop.='\''.$propType.'\'';
}
#Get the number of rooms
if(!empty($_GET['minRm'])||(!empty($_GET['maxRm']))){
$minroom = isset($_GET['minRm'])?$_GET['minRm']:'0';
$minRoom=' AND (num_bedrm>='.'\''.$minroom.'\'';
$maxroom = isset($_GET['maxRm'])?$_GET['maxRm']:NULL;
$var.='OR num_bedrm<='.'\''.$maxroom.'\'';
$var.=')';
}
#Get the price range
if(!empty($_GET['pRange'])){
$pRange=isset($_GET['pRange'])?$_GET['pRange']:NULL;
$var.=' AND price_range=';
$var.='\''.$pRange.'\'';
}
#check the variable to ensure it is not empty
if(!empty($var)){
$var.=' AND ';
}
#get whether it is for sale or rent
if(!empty($_GET['cat'])){
$var.='transType=';
$cat=($_GET['cat']=='rent')? 'rent':'sale' ;
$var.='\''.$cat.'\'';
}
#Get the location
if(!empty($_GET['location'])){
$var .= ' AND location=';
$var .='\'';
$var.=($_GET['location']=='')?NULL:$_GET['location'];
$var .='\'';
}
$req = "SELECT * FROM properties WHERE $var";
$req1= mysqli_query($conn,$req);
$numResult = mysqli_num_rows($req1);
$curPage = isset($_GET['page'])? $_GET['page'] : 1;
$limit = 4;
$numPages = ceil($numResult/$limit);
$start = ($curPage-1)*4;
include("pagination2.php"wink;
displayResult($var,$limit,$start);
echo $displayRes;
echo "<p>";
showLinks($var,$curPage,$numPages);
echo '<div style="clear:both; padding-top: 10px; padding-bottom:10px">'.$pageLinks."</div>";
?>
Re: Php Assistance by sayhi2ay(m): 8:07pm On Jul 23, 2010
what is the error you are getting?
Re: Php Assistance by frs6688: 9:54pm On Jul 23, 2010
I don't know,I want to learn!
Re: Php Assistance by Nobody: 11:32am On Jul 24, 2010
when you post a programming programming without displaying error message. . . .or showing an online sample. . .
Re: Php Assistance by jeshurun07: 2:03pm On Jul 27, 2010
sry guys,
problem solved! grin
Re: Php Assistance by DualCore1: 4:32pm On Jul 27, 2010
Still go ahead to post what the error was and how it was solved.
Re: Php Assistance by Nobody: 4:08pm On Jul 28, 2010
exactly

(1) (Reply)

10 Ways Of Making Money Online / Fairly Used Dish / Special Offer

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 11
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.