This topic is locked

COUNT Function - Query Designer

2/17/2009 3:31:59 PM
PHPRunner General questions
N
nicolagrimshaw author

Hi,
I am compiling a list of properties and want to provide a link, like on the Vacation template, to all 4 bedroom properties and then COUNT.
The query I would be using would be (I think):
SELECT COUNT(*) FROM 'property' WHERE Bedrooms='4 Bedrooms'
Is it possible to add this to the query designer, if so, how do I go about it?
Thanks in advance
Nicola

U
Urnso 2/17/2009

Hi,

I am compiling a list of properties and want to provide a link, like on the Vacation template, to all 4 bedroom properties and then COUNT.
The query I would be using would be (I think):
SELECT COUNT(*) FROM 'property' WHERE Bedrooms='4 Bedrooms'
Is it possible to add this to the query designer, if so, how do I go about it?
Thanks in advance
Nicola


Hi There, I think the would work (your query) I am new to those but you can always test your queries by using the tab next to query designer.
Change the code that is in there to yours and see if it works.
Good luck!

N
nicolagrimshaw author 2/17/2009



Hi There, I think the would work (your query) I am new to those but you can always test your queries by using the tab next to query designer.
Change the code that is in there to yours and see if it works.
Good luck!


Hi Urnso and thank you - I'd never realised the results tab was there!!!!
Unfortuantely it doesn not work, although I have tested it in PHPMyAdmin and it does work....
Anyone else have any ideas?
Nicola

N
nicolagrimshaw author 2/17/2009

I have tried to do this another way, by amending the events code shown on the Vacation template

global $strSQL, $conn, $xt;
$strMenu="";
$rstt = CustomQuery("SELECT Bedrooms , Count(Bedrooms) as `Count` FROM property group by Bedrooms");

$strMenu.="<table width=150 border=0><tr><td align=left height=20 class=blackshade><Font face=Tahoma><b>&nbsp;Search By Bedrooms</b></Font></td></tr>";

while($rstmp2=db_fetch_array($rstt))

{

$Bedrooms = str_Replace(" ","+",$rstmp2["Bedrooms"]);

$strMenu.="<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=property_list.php?a=search&value=1&SearchFor=" . $Bedrooms . "&SearchOption=Equals&SearchField=Bedrooms><Font face=Tahoma>";

$strMenu.=$rstmp2["Bedrooms"] . " (" . $rstmp2["Count"] . ")</font></a></td></tr>";

}

$strMenu.="<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Font face=Tahoma><a href=property_list.php?a=search&value=1&SearchFor=&SearchOption=&SearchField=FromPrice>Show All</a></font></td></tr></table>";
$strMenu.="<table width=150 border=0><tr><td align=left height=20 class=blackshade><Font face=Tahoma><b>&nbsp;Search By Price</b></Font></td></tr>";

$strMenu.="<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Font face=Tahoma><a href=property_list.php?a=search&value=1&SearchFor=500&SearchOption=Equal+or+less+than+...&SearchField=FromPrice>£300 or Less</a></font></td></tr>";

$strMenu.="<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Font face=Tahoma><a href=property_list.php?a=search&value=1&SearchFor=1000&SearchOption=Equal+or+less+than+...&SearchField=FromPrice>£400 or Less</a></font></td></tr>";

$strMenu.="<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Font face=Tahoma><a href=property_list.php?a=search&value=1&SearchFor=1500&SearchOption=Equal+or+less+than+...&SearchField=FromPrice>£500 or Less</a></font></td></tr>";

$strMenu.="<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Font face=Tahoma><a href=property_list.php?a=search&value=1&SearchFor=2000&SearchOption=Equal+or+less+than+...&SearchField=FromPrice>£600 or Less</a></font></td></tr>";

$strMenu.="<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Font face=Tahoma><a href=property_list.php?a=search&value=1&SearchFor=2500&SearchOption=Equal+or+less+than+...&SearchField=FromPrice>£750 or Less</a></font></td></tr>";

$strMenu.="<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Font face=Tahoma><a href=property_list.php?a=search&value=1&SearchFor=3000&SearchOption=Equal+or+less+than+...&SearchField=FromPrice>£850 or Less</a></font></td></tr>";

$strMenu.="<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Font face=Tahoma><a href=property_list.php?a=search&value=1&SearchFor=3500&SearchOption=Equal+or+less+than+...&SearchField=FromPrice>£1000 or Less</a></font></td></tr>";

$strMenu.="<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Font face=Tahoma><a href=property_list.php?a=search&value=1&SearchFor=4000&SearchOption=Equal+or+less+than+...&SearchField=FromPrice>£1500 or Less</a></font></td></tr>";

$strMenu.="<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Font face=Tahoma><a href=property_list.php?a=search&value=1&SearchFor=4500&SearchOption=Equal+or+less+than+...&SearchField=FromPrice>£2000 or Less</a></font></td></tr>";

$strMenu.="<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Font face=Tahoma><a href=property_list.php?a=search&value=1&SearchFor=&SearchOption=&SearchField=FromPrice>Show All</a></font></td></tr></table>";



$xt->assign("row00strMenu_value",$strMenu);


Yesterday when I tried it, I kept getting errors and today, I have tried again and although it does not work there it is not visible on the property_list page! Any ideas where I'm going wrong??????
Thanks
Nicola

J
Jane 2/18/2009

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.