$searchtext = str_replace(";", " ", $textinput); $searchtext = "%" . mysql_real_escape_string($searchtext) . "%"; //$searchtext = "%" . mysql_escape_string($searchtext) . "%"; // use this for older PHP versions $addstr = ""; if ($mode == 2) { // get other searchable fields $qstr02 = "SHOW FULL COLUMNS FROM {$datatable}"; $result02 = mysql_query($qstr02) or die("Query failed (#1a)!"); while ($line02 = mysql_fetch_array($result02)) { $fieldname = $line02["Field"]; $fieldtype = $line02["Type"]; $comment = $line02["Comment"]; $pos = strpos($comment, ">>>>"); if ($pos !== false) { $fieldprop = getfieldprop($comment); $searchabletype = is_stringtype($fieldtype); // should be checked! (only char, varchar, text, enum, set) if ($fieldprop["searchmode"] == 1 && $searchabletype == 1) { $addstr .= " OR (" . $fieldname . " LIKE \"{$searchtext}\")"; } } } mysql_free_result($result02); } // if ($mode == 2) $limit = $maxhits + 1; $qstr = "SELECT {$idname} FROM {$datatable} WHERE ({$namename} LIKE \"{$searchtext}\") {$addstr} GROUP BY {$idname} LIMIT {$limit}"; //echo "$qstr <br>\n"; $result = mysql_query($qstr) or die("Query failed (#1b)!"); $hits = 0; $nhits = mysql_num_rows($result);
} if ($newtype == "yn") { $nt = "ENUM('Y','N')"; } if ($newtype == "custom") { $nt = $newcustomtype; } if ($nt == "") { $nt = "VARCHAR(255)"; } // fallback if ($newoptions == "") { $newoptions = "NOT NULL"; } // check if field type is appropriate for text search if (is_stringtype($nt) == FALSE) { $newsearch = "0"; } $comment = ">>>>" . $newlabel . "<" . $newformat . "<" . $newsdflabel . "<" . $newsearch . "<<"; if ($newfield != "") { $updstr = "ALTER TABLE {$tbl} CHANGE {$newfield} {$newfield} {$nt} {$newoptions} COMMENT '{$comment}'"; #echo "$updstr <br />"; $result1 = mysql_query($updstr); $err = mysql_errno(); #mysql_free_result($result1); if ($err != 0) { echo "Action failed ({$err})<br />\n"; } } } echo "<h3>Data fields for data collection \"{$name}\"</h3>\n";