Re: SQL statement syntaxis

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux