RE: [PHP] Re: Help: Database Search
| From: | Stuart Felenstein | Date: | Sat, 13 Nov 2004 12:38:36 +0000 |
| Subject: | RE: [PHP] Re: Help: Database Search | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-201902@lists.php.net to get a copy of this message | ||
I think I'm almost there :)
Only right now I'm getting an error message:
"Query failed: 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 '' at line 3"
<?php
$where = array();
$Ind = "";
$Ind = $_POST['Ind'];
if (count($Ind) > 1)
{
$IndStr = implode("','", $Ind);
$where[] = "VendorJobs.Industry IN($IndStr)";
}else{
$where[] = "VendorJobs.Industry = {$Ind[0]}";
}
?>
<?php
$sql = 'SELECT PostStart, JobTitle, Industry,
LocationState, VendorID
FROM VendorJobs
WHERE ' . implode( ' AND ', $where );
$result = mysql_query($sql) or die ("Query failed: "
.mysql_error());
while($row = mysql_fetch_assoc($result))
I can't find the problem.
Anyone see anything ?
Thank you.
Stuart