jordz Posted March 1, 2010 Share Posted March 1, 2010 The best example of this would be a database full of plane models and types. For example In the field planemodel I have: 747-400 747-4AC 747-450 747-345 747-231 747-492 How would I query the database just to return everything where it has 747-4 or 747-2 in it? Thanks a lot , Jordan Link to comment https://forums.phpfreaks.com/topic/193786-how-to-query-some-of-a-field-let-me-explain-what-i-mean/ Share on other sites More sharing options...
inversesoft123 Posted March 1, 2010 Share Posted March 1, 2010 $result = "SELECT * FROM pf_planes WHERE model LIKE '%$input%'"; // ORDER by id DESC while($res=mysql_fetch_array($result)) { Link to comment https://forums.phpfreaks.com/topic/193786-how-to-query-some-of-a-field-let-me-explain-what-i-mean/#findComment-1019946 Share on other sites More sharing options...
jordz Posted March 1, 2010 Author Share Posted March 1, 2010 Thanks! Now Ive just had a thought, If someone were to enter into a search box 737-300, is there some way to query that and return results 737-321 etc with out having to say: if($search == '737-300'){ do this and have lots of code for each search to parse out the crap. } Thanks in advance. Jordan Link to comment https://forums.phpfreaks.com/topic/193786-how-to-query-some-of-a-field-let-me-explain-what-i-mean/#findComment-1019975 Share on other sites More sharing options...
inversesoft123 Posted March 1, 2010 Share Posted March 1, 2010 $result = "SELECT * FROM pf_planes WHERE model LIKE '%$input%'"; // ORDER by id DESC while($res=mysql_fetch_array($result)) { //// ACTUAL RESULTS } $related = substr($input,0,5); $relatedresult = "SELECT * FROM pf_planes WHERE model LIKE '%$related%'"; // ORDER by id DESC while($res=mysql_fetch_array($relatedresult)) { //// RELATED RESULTS } Link to comment https://forums.phpfreaks.com/topic/193786-how-to-query-some-of-a-field-let-me-explain-what-i-mean/#findComment-1019978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.