Jessie K. Jepsen Posted October 9, 2012 Share Posted October 9, 2012 Can someone please look at this code and tell me why its not working? It is supposed to let me search for a customer in my database by zipcode/postcode or first name or last name. but something does not seem to be working cause when I type in any of the above nothing populates from the database. Thank you for any help. This is from the Orlique Order Manager, but they wont help me at all with this.. So I would appreciate any help someone on this forum can give me.. -------------------------------------------------------------------------------------------------------------- /* * Returns a list of customers for an autofill box * * @access public * @param string $query - A search query to search the database for * * @return void */ public function ajaxCustomerList($query) { if ( ! $query || $query == '' || strlen($query) < 1) die(); $sql = ' SELECT c.`id_customer` , x.`firstname` , x.`lastname` , xl`postcode` FROM `' . _DB_PREFIX_ . 'customer` x LEFT JOIN `' . _DB_PREFIX_ . 'address` xl WHERE ( x.`firstname` LIKE "%' . pSQL($query) . '%" OR x.`lastname` LIKE "%' . pSQL($query) . '%" OR CONCAT(x.`firstname`, " ", x.`lastname`) LIKE "%' . pSQL($query) . '%" OR xl.`postcode` LIKE "%' . pSQL($query) . '%" )'; $customers = Db::getInstance()->ExecuteS($sql); if ($customers && sizeof($customers)) foreach ($customers as $customer) printf("%s %s | %d\n", $customer['firstname'], $customer['lastname'], (int)$customer['postcode']); } --------------------------------------------------------------------------------------------------------------------- Link to comment Share on other sites More sharing options...
netmechanics Posted October 29, 2012 Share Posted October 29, 2012 Hi - what version are you using of Presta? I have a similar problem in that on 1.5.1 this worked... if ($productdump = Db::getInstance()->query($sql)) {//debugforeach ($productdump as $row) { echo $row['id_product'] . ' :: ' . $row['name'];} But not on 1.5.2 !!! Link to comment Share on other sites More sharing options...
CartExpert.net Posted October 31, 2012 Share Posted October 31, 2012 Hi. The query is not correct. - xl`postcode` should be xl.`postcode` - the LEFT JOIN syntax is incorrect, it is missing the: ON (x.id_customer = xl.id_customer) Regards. Robin. The CartExpert Team Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now