Jump to content

Can you tell me whats wrong with this?


Recommended Posts

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

  • 3 weeks later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...