ruạṛ
<?php /** * return product paths and ids for associated products autocomplete * @version 0.9 * @author Robert Urquhart <programmer@activate_design.co.nz> * @since caravancamping.co.nz * @package WEP-CMS */ /* * load site data and definitions * @var string $include_path - for easy global search/replace if include location changes */ $include_path = $_SERVER['DOCUMENT_ROOT'].'/admin/scripts-includes/'; require_once $include_path.'universal.php'; require_once $include_path.'functions.php'; $connID = connect_to_db(); /** * get and clean form data * @var string $term submitted by autofill */ $term = clean_plain_data($_GET['term']); $return = array(); if($term != '') { $product_dir = select_one('page_data','path','page_type','products'); $query = "select prod_id, product_path from products where product_name like '%$term%' order by product_name, product_path"; $result = mysql_query($query) or die(mysql_error()); if($result and mysql_num_rows($result) > 0) { while($row = mysql_fetch_assoc($result)) { //$return[] = rtrim(ltrim($row[0],$product_dir),'/'); $return[] = array('label' => $row['product_path'], 'value' => $row['prod_id']); } } else { // $return[] = 'No results found'; //testing } } echo json_encode($return); exit; ?>
cải xoăn