item search working

This commit is contained in:
color.diff=auto
2021-03-30 13:40:11 -06:00
parent 3eadaac01e
commit 02527a0d65
8 changed files with 181 additions and 89 deletions

View File

@@ -49,14 +49,22 @@ if (!empty($_GET['sort']))
$sort = $_GET['sort'];
if (!empty($_GET['view']))
$view = $_GET['view'];
/*
* @cmd = getUniqueItem
*
*
* */
if ($cmd == "getUniqueItem") {
$sql = "SELECT * FROM `uniqueitems` WHERE `enabled`='1' AND `index`=\"{$_GET['index']}\"";
$res = PDO_FetchRow($sql);
header('Content-Type: application/json');
echo json_encode($res, JSON_INVALID_UTF8_IGNORE);
}
/*
* @cmd = sortBy
*
*
* */
if ($cmd == "sortBy") {
$sql = "SELECT `index`,`$sort` FROM `uniqueitems` WHERE `enabled`='1' ORDER BY `$sort`";
$res = PDO_FetchAll($sql);
@@ -66,12 +74,16 @@ if ($cmd == "sortBy") {
if ($sort == 'index') {
$html .= "<option value=\"{$r['index']}\">{$r['index']}</option>";
} else {
$html .= "<option value=\"{$r['index']}\">{$r['index']} ($r[$sort])</option>";
$html .= "<option value=\"{$r['index']}\">$r[$sort] - {$r['index']}</option>";
}
}
echo $html;
}
/*
* @cmd = viewOnly
*
*
* */
if ($cmd == "viewOnly") {
$table = 'misc';
@@ -93,14 +105,10 @@ FROM uniqueitems
LEFT JOIN $table ON uniqueitems.`code` = $table.`code`
WHERE `type` IS NOT NULL AND uniqueitems.`code`= $table.`code` AND $table.`code` != '' ORDER BY `index`";
}
if ($view == "char") {
$sql .= " OR uniqueitems.`code`='cm1' OR uniqueitems.`code`='cm2' OR uniqueitems.`code`='cm3'";
}
$res = PDO_FetchAll($sql);
$html = '';
foreach ($res as $r) {
if ($sort == 'index') {
@@ -111,3 +119,28 @@ WHERE `type` IS NOT NULL AND uniqueitems.`code`= $table.`code` AND $table.`code`
}
echo $html;
}
/*
* @cmd = search
*
*
*
*
*/
if ($cmd == 'search'){
$search = $_GET['search'];
$sql = "SELECT * FROM uniqueitems WHERE `index` LIKE '%$search%' OR `code` LIKE '%$search%' AND `enabled`=1 ORDER BY `index`";
$res = PDO_FetchAll($sql);
$html = '';
foreach ($res as $r) {
if ($sort == 'index') {
$html .= "<option value=\"{$r['index']}\">{$r['index']}</option>";
} else {
$html .= "<option value=\"{$r['index']}\">{$r['index']}</option>";
}
}
echo $html;
}