₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,329,301 members, 8,439,825 topics. Date: Monday, 06 July 2026 at 05:26 AM

Toggle theme

Php Assistance - Webmasters - Nairaland

Nairaland ForumScience/TechnologyWebmastersPhp Assistance (689 Views)

1 Reply (Go Down)

Php Assistance by jeshurun07(op): 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(op): 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

Is Anyone Using The Opencart Ecommerce Solution? Your Assistance Is Needed234

Get Adsense Code Into Your WebsiteEnd Of The Month Webhosting PromoSearch Free Downloads And Torrents