takn25 Posted March 2, 2011 Share Posted March 2, 2011 Hi I bought a script to search mysql database and its working great. The thing I am after is I have a row called Now in my database. Now can either be 0 or 1 what I want the script to do is search something like && WHERE now='1' the problem I am facing is the script is not well commented and the query part is kinda confusing could some one take a look and tell me what and where can I make the changes for the desired result thanks a bunch! // table fields to search $arrayFields = array(0 => $first_field, 1 => $second_field, 2 => $third_field, 3 => $fourth_field ); $countSearch = count($arraySearch); $a = 0; $b = 0; $query = "SELECT * FROM $table_name WHERE ("; $countFields = count($arrayFields); while ($a < $countFields) { while ($b < $countSearch) { $query = $query."$arrayFields[$a] LIKE '%$arraySearch[$b]%'"; $b++; if ($b < $countSearch) { $query = $query." AND "; } } $b = 0; $a++; if ($a < $countFields) { $query = $query.") OR ("; } } $query = $query.") LIMIT $offset, $records_number;"; $search = mysql_query($query); // get number of search results $arrayFields = array(0 => $first_field, 1 => $second_field, 2 => $third_field, 3 => $fourth_field ); $countSearch = count($arraySearch); $a = 0; $b = 0; $query = "SELECT * FROM $table_name WHERE ("; $countFields = count($arrayFields); while ($a < $countFields) { while ($b < $countSearch) { $query = $query."$arrayFields[$a] LIKE '%$arraySearch[$b]%'"; $b++; if ($b < $countSearch) { $query = $query." AND "; } } $b = 0; $a++; if ($a < $countFields) { $query = $query.") OR ("; } } $query = $query.")"; $count_results = mysql_query($query); $numrows = mysql_num_rows($count_results); Link to comment https://forums.phpfreaks.com/topic/229347-hi-need-a-bit-of-help/ Share on other sites More sharing options...
QuickOldCar Posted March 2, 2011 Share Posted March 2, 2011 you add in your queries AND now='1' Link to comment https://forums.phpfreaks.com/topic/229347-hi-need-a-bit-of-help/#findComment-1181713 Share on other sites More sharing options...
takn25 Posted March 2, 2011 Author Share Posted March 2, 2011 thanks I figured this much out but the problem I am facing is cant figure out the location where to insert and now='1' tried inserting in a few places but no luck :/ Link to comment https://forums.phpfreaks.com/topic/229347-hi-need-a-bit-of-help/#findComment-1181714 Share on other sites More sharing options...
takn25 Posted March 2, 2011 Author Share Posted March 2, 2011 Never mind figured it out thanks a bunch! Link to comment https://forums.phpfreaks.com/topic/229347-hi-need-a-bit-of-help/#findComment-1181717 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.