Jump to content


Photo

help with form hanadling/query


  • Please log in to reply
4 replies to this topic

#1 REOL

REOL
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 15 August 2006 - 02:41 PM

i need to help query out the following;

<FORM method="get" name="find" action="<?php $_SERVER['PHP_SELF'] ?>">

<table>
<tr>
<td align="center" colspan="3"><span class="formheadsmall">Rent ($ per Square Foot)</span></td>
<td></td>
<td colspan="3" align="center"><span class="formheadsmall">Square Footage</span></td>
</tr>
<tr>
<td valign="top">
<span class="formheadsmall">Minimum</span><br>
<input class="small" type="text" size="5" name="minimum_rent" value="0" /></td>
<td><img src="images/null.gif" height="1" width="24"></td>
<td valign="top"><span class="formheadsmall">Maximum</span><br>
<input class="small" type="text" size="5" name="maximum_rent" value="300" /></td>
<td><img src="images/null.gif" width="48"></td>
<td valign="top"><span class="formheadsmall">Minimum</span><br>
<input class="small" type="text" size="5" name="minimum_space" value="0" /></td>
<td><img src="images/null.gif" height="1" width="24"></td>
<td valign="top"><span class="formheadsmall">Maximum</span><br>
<input class="small" type="text" size="5" name="maximum_space" value="200000" /></td>
</tr>
</table>
<table>
<tr>
<td><span class="formheadsmall">Office :: Retail</span><br>
<select class="small" name="isRetail">
<option value="-1">ALL</option>
<option value="0">Office</option>
<option value="1">Retail</option></select></td>
<td><img src="images/null.gif" height="1" width="24"></td>
<td><span class="formheadsmall">Prebuilt</span><br>
<select class="small" name="isPrebuilt">
<option value="-1">ALL</option>
<option value="1">Yes</option>
<option value="0">No</option></select></td>
</tr>
</table><br><table>
<tr>
<td valign="top"><span class="formheadsmall">Properties</span><br>
<select class="small" multiple="yes" size="4" name="PropertyList">
<option value="all" selected>All Properties</option>
<?
$properties = getProperties( 'id' );
foreach ( $properties as $property )
{
$selected = ($property_id == $property['id']) ? "selected" : "";
echo "<option $selected value='$property[id]'>$property[address]</option>";
}
?>
</select>
</td>
<td><img src="images/null.gif" height="1" width="18"></td>
<td valign="top">
<span class="formheadsmall">District</span><br>
<select class="small" multiple="yes" size="4" name="DistrictList">
<option value="all" selected>All Districts</option>
<?
$districts = getDistricts();
foreach ( $districts as $district ) 
{ 
$selected = ($district_id == $district['id']) ? "selected" : "";
echo "<option value='$district[districtid]'>$district[name]</option>";
}
?>
</select></td>
</tr>
<tr><td><img src="images/null.gif" width="1" height="6"></td></tr>
<tr>
<td><span class="formheadsmall">Sort Results</span><br>
<select class="small" name="sort">
<option value="0">By Property/Floor</option>
<option value="1">By Rent</option>
<option value="2">By Square Footage</option>
</select></td>
<td><img src="images/null.gif" height="1" width="6"></td>
<td valign="bottom" align="left"><input class="button" type="submit" value="Find Space" name="search" /></td>
</tr>
</table>
</form>


just need the correct way to input all values and find a common entity, in this case its  property_id


anyhelp would be great.  thanks.

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 August 2006 - 02:54 PM

what it dont do?

cheers?
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 REOL

REOL
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 15 August 2006 - 03:29 PM

a user will search using those fields and get a result by a property id#



#4 REOL

REOL
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 15 August 2006 - 03:34 PM

function getProperties( $sortcol = 'buildingcode')
{
	$query = "SELECT * FROM property WHERE isactive='t' order by $sortcol";
	$result = pgdbsql( $query, "web" );
	return $result;
}

function getProperty( $property_id )
{
	$query = "SELECT * FROM property WHERE id = $property_id";
	$result = pgdbsql( $query, "web" );
	return $result[0];
}

function getPropertyDistricts( $property_id )
{
	$query = "SELECT districtid FROM propertydistrict WHERE propertyid = $property_id";
	$result = pgdbsql( $query, "web" );

	$districts = array();
	foreach( $result as $district )
	{
		$districts[] = $district['districtid'];
	}
	return $districts;
}

function getPropertyLeasingContacts( $property_id )
{
	// 1 for leasing
	// 2 for building manager
	$query = "
		SELECT contact.* 
		FROM contact, property, propertycontact
		WHERE property.id = $property_id
		AND property.id = propertycontact.propertyid
		AND contact.id = propertycontact.contactid
		AND contact.contacttypeid = 1
	";
	$result = pgdbsql( $query, "web" );
	return $result;
}

function getPropertyManager( $property_id )
{
	// 1 for leasing
	// 2 for building manager
	$query = "
		SELECT contact.* 
		FROM contact, property, propertycontact
		WHERE property.id = $property_id
		AND property.id = propertycontact.propertyid
		AND contact.id = propertycontact.contactid
		AND contact.contacttypeid = 2
	";
	$result = pgdbsql( $query, "web" );
	return $result;
}

function getPropertyTag( $property_id )
{
	$query = "SELECT address FROM property WHERE id = $property_id";
	$result = pgdbsql( $query, "slgreenweb" );
	$address = strtolower( $result[0]['address'] );
	$address = join( "_", split( " ", $address ) );
	$address = join( "_", split( "/", $address ) );
	return $address;
}

function getPropertyPhotos( $property_id )
{
	global $UPLOAD_DIR;
	$property_tag = getPropertyTag( $property_id );

	$pattern = '/^photo_'.$property_tag.'/';

	$files = array();
	$dir = opendir( $UPLOAD_DIR );
	while( $f = readdir( $dir ) )
	{
		if( strcmp( $f, '.' ) == 0 || strcmp( $f, '..' ) == 0 ) continue;
		if( preg_match( $pattern, $f ) ){
			array_push( $files, $f );
		}
	}
	closedir($dir); 

	return $files;
}

function getSpaces( $property_id )
{
	$query = "SELECT space.*, property.* FROM space,property WHERE space.buildingid = property.id AND property.id = $property_id";
	$result = pgdbsql( $query, "web" );
	return $result;
}

function getSpace( $space_id )
{
	$query = "
		SELECT space.*, property.*, floortype.id as floortype_id, floortype.floorname as floortype_name 
		FROM space,property,floortype 
		WHERE space.buildingid = property.id 
		AND space.id = $space_id
		AND floortype.id = space.altfloorid
	";
	$result = pgdbsql( $query, "web" );
	return $result[0];
}

function getFloortypes()
{
	$query = "SELECT id, floorname as name FROM floortype";
	$result = pgdbsql( $query, "web" );
	return $result;
}

function getDistricts( $sortcol = "sort_order")
{
	$query = "SELECT id, districtname as name FROM district ORDER BY $sortcol";
	$result = pgdbsql( $query, "web" );
	return $result;
}

function getPropertiesByDistrict( $district_id )
{
	$query = "
		SELECT property.*
		FROM property, propertydistrict
		WHERE propertydistrict.districtid = $district_id
		AND propertydistrict.propertyid = property.id
		AND property.isactive=true
	";
	$result = pgdbsql( $query, "web" );
	return $result;
}

?>


above are the functions that relate to it.. mostly using getSpaces(); function.

as you can tell, it is a property search, where it searches min-max ($) in rent, min-max in sqfeet the property that is chosen and the district the property is in.
also they can sort the results using the sort form.

im always having some trouble queriying all the info out to relate to $id, so the results will read like ,  mypage.php?id=($property_id of search results)

thanks for all the help.

#5 REOL

REOL
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 16 August 2006 - 01:44 PM

anyone can help?

-ps




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users