Sarajs Posted January 24, 2009 Author Share Posted January 24, 2009 this really isn't working because I have multiple search fields . I hate to be a burden but my deadline is Friday x Link to comment https://forums.phpfreaks.com/topic/142195-please-help-with-my-error/page/2/#findComment-745434 Share on other sites More sharing options...
uniflare Posted January 24, 2009 Share Posted January 24, 2009 If this is a paid job i would charge extra time/money for a search engine simply because a search engine can be a VERY complicated feature, especially if you've never done it before. --- FYI it should not matter with "multiple" search fields, something like: <?php // Build the query $query = array(); // If artist was needed, add it to the array if($cd_artist != ""){ $query[] = "`artist` LIKE '%".$cd_artist."%'"; } // blah blah for all other fields if($cd_title != ""){ $query[] = " `title` LIKE '%".$cd_title."%'"; } if($cd_genre != ""){ $query[] = " `genre` LIKE '%".$cd_genre."%'"; } if($cd_year != ""){ $query[] = "`year` LIKE '%".$cd_year."%'"; } if($cd_type != ""){ $query[] = "`type` LIKE '%".$cd_type."%'"; } // now you have an array with only the searches u need. Implode them into a single string with OR between each item; $query = "SELECT * FROM tProducts WHERE ".implode(" OR ",$query)." ORDER BY `artist`"; // put OR between each search. $result = mysql_query($query); // This loop ust displays each result while($row=mysql_fetch_array($result)){ print_r($row); echo("<br />"); } ?> Hope this clears things up for you. Link to comment https://forums.phpfreaks.com/topic/142195-please-help-with-my-error/page/2/#findComment-745512 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.