Jump to content

Recommended Posts

I don't see how you are doing php on a page with an html extension.  I also don't see anywhere where you've identified the property you are viewing.  I suppose if you only have one record in the `images` table then it could call up the expected results but again running php on an html page is not the norm and I'm surprised you are seeing anything.  My suggestion still stands as the best answer.

  • Replies 84
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

On insert.php you'd do something like this.

while($row = mysql_fetch_assoc($results)){
	echo '<div class="container" style="float:left;">';
	echo '<div class="imageholder" style="float:left;">';
	echo "<a href=\"propertyinfo.php?id={$row['id']}\"><img class='image1' src=\"{$row['image_path']}\" alt=\"{$row['summary']}\"> </a> <br />";
	echo '</div>';
	echo '<div class="textholder" style="font-family:helvetica; font-size:14px; float:left; padding-top:10px;">';
	echo "{$row['summary']}";
	echo "<span style=\"color:#63be21;\"><br><br><b>{$row['bedrooms']} bedroom(s) {$row['bathrooms']} bathroom(s) {$row['receptions']} reception room(s)</b></span>";
	if($row['parking'] != null){
		echo "<span style=\"color:#63be21;\"><b> {$row['parking']} parking space(s)</b></span>";
	}

 

On propertyinfo.php you need to pick up this GET value and add it to your query.

 

if (isset($_GET['id']) && is_numeric($_GET['id'])){

	//Do your queries WHERE id='{$_GET['id']}'

etc.  Adjust for table field names e.g. property_id for images etc.

 

Note: I have not downloaded current code so adjust as needed.

OK usman, you should be able to delete the extra column you added to the database and go back to our original structure.  changing the code on insert.php to the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>Mumtaz Properties</title>
	<link rel="stylesheet" href="cutouts/style.css"/>
</head>

<body>
<!--Main Div Tag-->
	<div id="wrapper">

		<div id="header">
			<div id="logo"><a href="index.html"><img src="cutouts/Homepage/logo.png" alt=""/></a></div>
		</div>

<div id="navigation">
<a id="Home" href="index.php" title="home"><span>home</span></a>
<a id="Sale" href="forsale.html" title="for sale"><span>for sale</span></a>
<a id="Rent" href="forrent.html" title="for rent"><span>for rent</span></a>
<a id="Contact" href="contact.html" title="contact us"><span>contact us</span></a>
</div>

<div id="main">
<div id="results"><img src="cutouts/Homepage/results.png"></img></div>
<?php
require_once 'mstr_ref.php';
function san($input){
if(get_magic_quotes_gpc()){
	$input=stripcslashes($input);
}
$output = mysql_real_escape_string($input);
return $output;
}
if(isset($_POST['submit'])){
$pVars = array('area'=>$_POST['areas'], 'propType'=>$_POST['prop_type'], 'saleType'=>$_POST['ptype'], 'minB'=>$_POST['min_bedrooms'], 'maxB'=>$_POST['max_bedrooms'], 'minP'=>$_POST['min_price'], 'maxP'=>$_POST['max_price']);
foreach ($pVars as $k=>$v){
	$v = san($v);
}
$sql = new makeQuery();
$sql->manAdd('location_id', $pVars['area']);
if($pVars['propType'] != 'Any'){
	$sql->manAdd('catagory_id', $pVars['propType']);
}
if ($pVars['maxB'] > 0){
	$sql->manAdd('bedrooms', $pVars['maxB'], '<=');
}
if($pVars['minB'] > 0){
	$sql->manAdd('bedrooms',$pVars['minB'],'>=');
}
if($pVars['saleType'] != 'Any'){
	if($pVars['saleType'] == "forsale"){
		$sql->manAdd('market_type', 'sale');
		if($pVars['minP'] != 0){
			$pVars['minP'] = $pVars['minP'] * 1000;
		}
		if($pVars['maxP'] != 0){
			$pVars['maxP'] = $pVars['maxP'] * 1000;
		}
	}
	if($pVars['saleType'] == 'forrent'){
		$sql->manAdd('market_type', 'rent');
	}
}

$qry = $sql->sqlStart.$sql->stmt.'Group By property.id';
$results = mysql_query($qry) or die (mysql_error()."<br />|-|-|-|-|-|-|-|-|-|-|-|-<br />$qry");
if(mysql_num_rows($results) < 1){
	die ("Sorry, No Results Match Your Search.");
}
while($row = mysql_fetch_assoc($results)){
	echo '<div class="container" style="float:left;">';
	echo '<div class="imageholder" style="float:left;">';
	echo "<a href='detail.php?prop={$row['id']}'><img class='image1' src='{$row['image_path']}' alt='{$row['summary']}' /></a> <br />";
	echo '</div>';
	echo '<div class="textholder" style="font-family:helvetica; font-size:13px; float:left; padding-top:10px;">';
	echo "Summary : {$row['summary']}";
	echo "A {$row['bedrooms']} bedroom, {$row['bathrooms']} bathroom {$row['cat_name']} in {$row['area_name']}, With {$row['receptions']} reception room(s)<br>";
	if($row['parking'] != null){
		echo "This property has {$row['parking']} parking";
	}
	if($row['pay_interval'] != null){
		echo " This proerty is available for £{$row['asking_price']} per {$row['pay_interval']}";
	}
	else{
		echo " This property is on the market for £{$row['asking_price']},000";
	}
	echo '</div>';
	echo '<div style="clear:both"></div>';
}

}
else{
echo "There was a problem, please click<a href='index.php'> Here </a>to return to the main page and try again";
}
?>
</div>

</div>

</body>
</html>

and then adding the following page to the same directory naming it "detail.php":

<?php
require_once 'mstr_ref.php';
if(isset($_GET['prop'])){
$propID = $_GET['prop'];
$id = (int)$propID;

$sql = <<<SQL_SL
SELECT 	SELECT
 image_path,
 area_name,
 cat_name,
 bedrooms,
 bathrooms,
 receptions,
 parking,
 market_type,
 asking_price,
 summary,
 detail,
 pay_interval
FROM property
 INNER JOIN catagorys ON property.catagory_id = catagorys.id
 INNER JOIN locations ON property.location_id = locations.id
 LEFT JOIN images ON property.id = images.property_id
WHERE
property.id = $id
SQL_SL;

$results = mysql_query($sql) or die (mysql_error());
$counter = 0;
while ($row = mysql_fetch_assoc($results)){
	if($counter == 0){
		echo "{$row['area_name']}";
		echo "{$row['cat_name']}";
		echo "{$row['summary']}";
		echo "{$row['asking_price']}";
		echo "{$row['detail']}";
		echo "{$row['parking']}";
		echo "{$row['bedrooms']} bedrooms, ";
		echo "{$row['bathrooms']} bathrooms, ";
		echo "{$row['receptions']} reception rooms.";
		echo "<img src='{$row['image_path']}' alt='img{$counter}' />";
	}
	else{
		echo "<img src='{$row['image_path']}' alt='img{$counter}' />";
	}

}
}
else{
echo"No Property found. Please click <a href='index.php'>Here</a> to search again.";
}
?>

should get you your image linking to the detail per property.  You really do not need any column for url, and you should have never have added the url column to the images table anyway, unless you were planning for every image to link to a different page.  adding the column to the property table would have been the way to do it if it was a per property link that you wanted. but as we are already pulling the property ID out of the database we can just use that to requery for the details of that property by passing it in the url to the new details page.

 

It's not tested so will probably be a little buggy, but you should be getting to the point now where you can fix the little issues on your own.

 

Let us know how it goes.

this is insert.php with the search fixed aswell:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>Mumtaz Properties</title>
	<link rel="stylesheet" href="cutouts/style.css"/>
</head>

<body>
<!--Main Div Tag-->
	<div id="wrapper">

		<div id="header">
			<div id="logo"><a href="index.html"><img src="cutouts/Homepage/logo.png" alt=""/></a></div>
		</div>

<div id="navigation">
<a id="Home" href="index.php" title="home"><span>home</span></a>
<a id="Sale" href="forsale.html" title="for sale"><span>for sale</span></a>
<a id="Rent" href="forrent.html" title="for rent"><span>for rent</span></a>
<a id="Contact" href="contact.html" title="contact us"><span>contact us</span></a>
</div>

<div id="main">
<div id="results"><img src="cutouts/Homepage/results.png"></img></div>
<?php
require_once 'mstr_ref.php';
function san($input){
if(get_magic_quotes_gpc()){
	$input=stripcslashes($input);
}
$output = mysql_real_escape_string($input);
return $output;
}
if(isset($_POST['submit'])){
if((isset($_POST['min_price1']) && $_POST['min_price1'] != 0) || (isset($_POST['max_price1']) && $_POST['max_price1'] != 0)){
	$_POST['min_price'] = $_POST['min_price1'];
	$_POST['max_price'] = $_POST['max_price1'];
}
elseif((isset($_POST['min_price2']) && $_POST['min_price2'] != 0) || (isset($_POST['max_price2']) && $_POST['max_price2'] != 0)){
	$_POST['min_price'] = $_POST['min_price2'];
	$_POST['max_price'] = $_POST['max_price2'];
}
elseif((isset($_POST['min_price3']) && $_POST['min_price3'] != 0) || (isset($_POST['max_price3']) && $_POST['max_price3'] != 0)){
	$_POST['min_price'] = $_POST['min_price3'];
	$_POST['max_price'] = $_POST['max_price3'];
}
$pVars = array('area'=>$_POST['areas'], 'propType'=>$_POST['prop_type'], 'saleType'=>$_POST['ptype'], 'minB'=>$_POST['min_bedrooms'], 'maxB'=>$_POST['max_bedrooms'], 'minP'=>$_POST['min_price'], 'maxP'=>$_POST['max_price']);
foreach ($pVars as $k=>$v){
	$v = san($v);
}
$sql = new makeQuery();
$sql->manAdd('location_id', $pVars['area']);
if($pVars['propType'] != 'Any'){
	$sql->manAdd('catagory_id', $pVars['propType']);
}
if ($pVars['maxB'] > 0){
	$sql->manAdd('bedrooms', $pVars['maxB'], '<=');
}
if($pVars['minB'] > 0){
	$sql->manAdd('bedrooms',$pVars['minB'],'>=');
}
if($pVars['saleType'] != 'Any'){
	if($pVars['saleType'] == "forsale"){
		$sql->manAdd('market_type', 'sale');
		if($pVars['minP'] != 0){
//			$pVars['minP'] = $pVars['minP'] * 1000;
		}
		if($pVars['maxP'] != 0){
//			$pVars['maxP'] = $pVars['maxP'] * 1000;
		}
	}
	if($pVars['saleType'] == 'forrent'){
		$sql->manAdd('market_type', 'rent');
	}
}

if ($pVars['maxP'] > 0){
	$sql->manAdd('asking_price', $pVars['maxP'], '<=');
}
if($pVars['minP'] > 0){
	$sql->manAdd('asking_price',$pVars['minP'],'>=');
}


$qry = $sql->sqlStart.$sql->stmt.'Group By property.id';
$results = mysql_query($qry) or die (mysql_error()."<br />|-|-|-|-|-|-|-|-|-|-|-|-<br />$qry");
if(mysql_num_rows($results) < 1){
	die ("Sorry, No Results Match Your Search.");
}
while($row = mysql_fetch_assoc($results)){
	echo '<div class="container" style="float:left;">';
	echo '<div class="imageholder" style="float:left;">';
	echo "<a href='detail.php?prop={$row['id']}'><img class='image1' src='{$row['image_path']}' alt='{$row['summary']}' /></a> <br />";
	echo '</div>';
	echo '<div class="textholder" style="font-family:helvetica; font-size:13px; float:left; padding-top:10px;">';
	echo "Summary : {$row['summary']}";
	echo "A {$row['bedrooms']} bedroom, {$row['bathrooms']} bathroom {$row['cat_name']} in {$row['area_name']}, With {$row['receptions']} reception room(s)<br>";
	if($row['parking'] != null){
		echo "This property has {$row['parking']} parking";
	}
	if($row['pay_interval'] != null){
		echo " This proerty is available for £{$row['asking_price']} per {$row['pay_interval']}";
	}
	else{
		echo " This property is on the market for £{$row['asking_price']},000";
	}
	echo '</div>';
	echo '<div style="clear:both"></div>';
}

}
else{
echo "There was a problem, please click<a href='index.php'> Here </a>to return to the main page and try again";
}
?>
</div>

</div>

</body>
</html>

?Thanks so much Muddy_Funster. I'v tried that at the moment i'm getting this error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT image_path, area_name, cat_name, bedrooms, bathrooms, recepti' at line 1

I dont understand the detail.php, because what i want is when users make a search using the form,and results come up of properties, I want them to be able to click the image of a property and that will directly take them to another page with more information of that property that they selected. (The pages of ALL properties are already in the same directory. and they are .html pages)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.