Good morning
I need to know how I can exclude certain rows if a criteria
is not specified.
I am developing a property management website. On this
website are 1, 2 & 3 bedroom apartment listings. When a person
goes on to the site, they will choose how many bedrooms they are
looking for.
When they press the submit button, they will be taken to the
appropriate page where all the available bedrooms will show. The
only problem with this page is that it shows “all” of
the bedrooms, including the ones that are
“unavailable”. Is there any way to not show an
apartment if it is designated in my database as
”unavailable” ? the link to the website is
http://www.fulloccupancy.net/Form_Master_Apartment.cfm
Below is the code I inputted on my action page:
<cfquery name="Apt_Results"
datasource="BD_Foproperties">
SELECT FOUnitDescription.Location,
FOUnitDescription.PropertyName, FOUnitDescription.Available,
FOUnitDescription.Amenity, FOUnitDescription.Address,
FOUnitDescription.UnitNumber, FOUnitDescription.Bedroom,
FOUnitDescription.Bathroom, FOUnitDescription.SquareFootage,
FOUnitDescription.Rent
FROM FOUnitDescription
WHERE 0=0
AND bedroom
AND bathroom
AND Available<>unavailable
<!--- If Query Begin--->
<cfif bedroom IS NOT "">
AND Bedroom LIKE '%#bedroom#%'
</cfif>
<cfif bathroom IS NOT "">
AND Bathroom LIKE '%#bathroom#%'
</cfif>
<!---If Query End--->
ORDER BY FOUnitDescription.SquareFootage DESC, Rent DESC
</cfquery>
<!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>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>Apartment Search Results</title>
<script src="Scripts/AC_RunActiveContent.js"
type="text/javascript"></script>
<link href="CSS/FullOccupancyContainer.css"
rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
background-image: url(Image/Pattern3.jpg);
background-repeat: repeat;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style>
<link href="CSS/Footer.css" rel="stylesheet"
type="text/css" />
<style type="text/css">
<!--
.style10 {
color: #000000;
font-weight: bold;
}
.style14 {color: #000000}
.style15 {color: #BBE1F2}
-->
</style>
</head>
<body><br /><br />
<!---Header--->
<cfinclude template="Header.cfm">
<!---Header End--->
<div id="THCCOntainer">
<cfinclude template="NavBar.cfm">
<div id="Image Banner"><img name=""
src="Image/Banner_Static/Banner2.jpg" width="780" height="234"
alt="" /></div>
<div id="BeigeHorizontalBarTop"></div>
<div id="SideBarlinks">
<ul>
<span class="SideBarHeader1"></span>
<li><a href="Form_Master.cfm"
class="SideBarlinks">Find an Apartment</a></li>
<li class="style2">News Clippings</li>
<li><a href=""
class="SideBarlinks">Testimonials</a></li>
</ul>
</div>
<div id="Body">
<p class="BodyHeader1"> </p>
<p>
<!---Display Apartment---><span
class="FO_Header1">Apartment Listings...
</span>
<br />
<br />
<cfoutput query="Apt_Results">
<span
class="FO_Header1_SmallFont"></span><span
class="FO_Header1_SmallFont">#CurrentRow#).</span><br
/>
<table width="501" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td valign="top" class="FO_Regular_Grey"
scope="col"> </td>
<td scope="col"><span
class="FO_Header1_SmallFont"> </span> <span
class="FO_Regularbold"><strong> Apartment:
</strong></span><span
class="PropertyName"><span
class="FO_Header1_SmallFont"><span class="FO_Regularbold">
#Apt_Results.UnitNumber#</span></span></span> at
#Apt_Results.Address#</td>
</tr>
<tr>
<td width="129" valign="top" class="FO_Regular_Grey"
scope="col"><strong></strong>
<div align="left"
class="FO_Regular">Feature</div></td>
<td width="372" scope="col"><div align="left"
class="FO_Header1_SmallFont"><span class="AvailiableText">
#Apt_Results.Bedroom#Bed, #Apt_Results.Bathroom#Bath
</span></div></td>
</tr>
<tr>
<td valign="top" class="FO_Regular">Located
at:</td>
<td class="FO_Regular">#Apt_Results.Address#,
Richmond, VA</td>
</tr>
<tr>
<td valign="top" class="FO_Regular style14">Square
Footage:</td>
<td class="FO_Regular"><div align="left"
class="FO_Regular style14"> #Apt_Results.SquareFootage#
Sqft.</div></td>
</tr>
<tr>
<td valign="top" class="style14"> </td>
<td class="FO_Regular style14"> </td>
</tr>
<tr>
<td valign="top" class="style14">Rent:</td>
<td class="FO_Regular style14">Please Call us to get
current rental
info.<!---$#Apt_Results.Rent#/Month---></td>
</tr>
<tr>
<td valign="top"> </td>
<td class="style14"> </td>
</tr>
<tr>
<td height="55" valign="top" class="FO_Regular
style14">Amenities: </td>
<td valign="top" class="FO_Regular
style14">#Apt_Results.Amenity#</td>
</tr>
<tr>
<td height="26" valign="top"
class="style10"> </td>
<td valign="top" class="FO_Header2_Orange"></td>
</tr>
</table>
<span class="FO_Regular">For more info on
#Apt_Results.UnitNumber#, p</span><span
class="FO_Regular">lease Call: <strong>804-643-0534
Ext.12</strong></span><br />
<span
class="style15">_______________________________________________________________________</span><br
/>
</cfoutput>
<!--- End --->
</div>
<div class="clear" id="BeigeHorizontalBar">
</div>
<!---Footer--->
<cfinclude template="Footer.cfm">
<!---Footer End--->
</div>
</html>