Re: SQL statement syntaxis
| From: | Joseph Crawford | Date: | Fri, 07 Jan 2005 01:15:27 +0000 |
| Subject: | Re: SQL statement syntaxis | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-38051@lists.php.net to get a copy of this message | ||
the syntax for that looks fine to me....
what you might want to try doing is something like this
if( isset( $_POST['CompanyName'] ) ) {
$query_company_listing = "SELECT CompanyID, CompanyName,
CompanyOrDepartment, BillingAddress, City, PostalCode, PhoneNumber FROM
company WHERE company.CompanyName=".$_POST['CompanyName']."
ORDER BY
CompanyName ASC";
} else {
$query_company_listing = "SELECT CompanyID, CompanyName,
CompanyOrDepartment, BillingAddress, City, PostalCode, PhoneNumber FROM
company
ORDER BY
CompanyName ASC";
}
Notice that the first one grabs the company names with the WHERE
clause only if the $_POST['CompanyName'] is set and not a null value,
i think the problem is that you are trying to use a variable that is
not set yet and your SQL evaluates to something like this
$query_company_listing = "SELECT CompanyID, CompanyName,
CompanyOrDepartment, BillingAddress, City, PostalCode, PhoneNumber FROM
company WHERE company.CompanyName= ORDER BY
CompanyName ASC";
Let me know if this is your problem or not :D
--
Joseph Crawford Jr.
Codebowl Solutions
codebowl@gmail.com