ajax.inc 598 B

12345678910111213141516171819
  1. <?php
  2. function uc_cartlinksbuilder_product_autocomplete($string = '') {
  3. if (empty($string)) {
  4. return NULL;
  5. }
  6. $sql = "SELECT n.nid, n.title, n.type, p.model FROM {node} n JOIN {uc_products} p on p.nid = n.nid WHERE n.title LIKE :string";
  7. $result = db_query($sql, array(':string' => '%' . $string . '%'));
  8. $matches = array();
  9. while ($row = db_fetch_object($result)) {
  10. $nid = $row->nid;
  11. // Add a class wrapper for a few required CSS overrides.
  12. $matches[$row->title . " [nid:$nid]"] = sprintf('(%s) %s', $row->model, $row->title);
  13. }
  14. drupal_json_encode($matches);
  15. }