php search coding with error - please help

hi

I am creating a php web but encountered this php search coding with errors.
my php testing web page is at http://seagift.biz/Jobs1/jobsjobs_list.php

[php]
//// php search coding
global $dal;
$message=“Search by Location
”;
////City
$dal_table=$dal->Table(“jobsjobs”);
$str = “select count(Id) as numbers, City from “.$dal_table->TableName().” group by City”;
$rs = CustomQuery($str);
while ($data = db_fetch_array($rs))
{
$City = str_replace(" “,”+",$data[“City”]);
$message.="<a href=“jobsjobs_list.php?ctlSearchFor=”.$City."&srchOptShowStatus=0&ctrlTypeComboStatus=0&srchWinShowStatus=0&a=integrated&id=1&criteria=and&value11=".$City."&field1=City&option1=Equals">".$data[“City”]." (".$data[“numbers”].")
";
////DateAdded
$str2 = “select count(Id) as numbers2, DateAdded from “.$dal_table->TableName().” where City=’”.$data[“City”]."’ group by DateAdded";
$rs2 = CustomQuery($str2);
while ($data2 = db_fetch_array($rs2))
{
$DateAdded = str_replace(" “,”+",$data2[“DateAdded”]);
$message.="     <a href=“jobsjobs_list.php?ctlSearchFor=”.$City."&srchOptShowStatus=0&ctrlTypeComboStatus=0&srchWinShowStatus=0&a=integrated&id=1&criteria=and&value11=".$DateAdded."&field1=DateAdded&option1=Equals">".$data2[“DateAdded”]." (".$data2[“numbers2”].")
";
}
}
$xt->assign(“ListOnLoad”,$message);
[/php]

1st scenario
when I click the Central [City] + 2014-11-21 (53) [DateAdded] . pls see attached locationCENTRAL.
I get the actual result seach => 53 of Central

2nd scenario WITH ERROR
when I click the East [City] + 2014-11-21 (31) [DateAdded] . pls see attached locationEAST.
I get the INCORRECT result seach =>71 of East [31], Central [1] & North-East [39]

could someone help me?
thanks a lot in advance


Hard to tell without seeing the full code, but it’s almost like you’re using a LIKE query (although I don’t see this in your code - you could have changed this in $data[‘city’] for all I know) as it’s only adding the East & North East together.

hi

thanks for replied

below is the script
[php]
//// php search coding
global $dal;
$message=“Search by Location
”;
////City
$dal_table=$dal->Table(“jobsjobs”);
$str = “select count(Id) as numbers, City from “.$dal_table->TableName().” group by City”;
$rs = CustomQuery($str);
while ($data = db_fetch_array($rs))
{
$City = str_replace(" “,”+",$data[“City”]);
$message.="<a href=“jobsjobs_list.php?ctlSearchFor=”.$City."&srchOptShowStatus=0&ctrlTypeComboStatus=0&srchWinShowStatus=0&a=integrated&id=1&criteria=and&value11=".$City."&field1=City&option1=Equals">".$data[“City”]." (".$data[“numbers”].")
";
////DateAdded
$str2 = “select count(Id) as numbers2, DateAdded from “.$dal_table->TableName().” where City=’”.$data[“City”]."’ group by DateAdded";
$rs2 = CustomQuery($str2);
while ($data2 = db_fetch_array($rs2))
{
$DateAdded = str_replace(" “,”+",$data2[“DateAdded”]);
$message.="     <a href=“jobsjobs_list.php?ctlSearchFor=”.$City."&srchOptShowStatus=0&ctrlTypeComboStatus=0&srchWinShowStatus=0&a=integrated&id=1&criteria=and&value11=".$DateAdded."&field1=DateAdded&option1=Equals">".$data2[“DateAdded”]." (".$data2[“numbers2”].")
";
}
}
$xt->assign(“ListOnLoad”,$message);
[/php]

I believe I need to add some coding under the script
[php]
$message.="     <a href=“jobsjobs_list.php?ctlSearchFor=”.$City."&srchOptShowStatus=0&ctrlTypeComboStatus=0&srchWinShowStatus=0&a=integrated&id=1&criteria=and&value11=".$DateAdded."&field1=DateAdded&option1=Equals">".$data2[“DateAdded”]." (".$data2[“numbers2”].")
";
[/php]

because if I used n click advanced search, please see attached locationAdvancedSearch11.jpg

then I manually choose City, Equals n type east n manually choose Posted, Equals n 21 nov 2014. please see attached, locationAdvancedSearch22.jpg

then the final result is east => 31 , east n 21 nov 2014. pls see attached locationAdvancedSearch33.jpg

u can go to live website at http://seagift.biz/Jobs1/jobsjobs_list.php

please help
thanks


Is DateAdded datatype of DATE, DATETIME, or TIMESTAMP?
That may effect your results.

On a side note:
It’s considered bad practice to name your table columns with camel casing in MySQL.

Sponsor our Newsletter | Privacy Policy | Terms of Service