watsmyname Posted April 26, 2011 Share Posted April 26, 2011 Hello, Let's say my database table field has following rows ID TITLE 1 2008 Toyota Tundra 2WD Truck at 12664 W. Colonial Drive. 2 2007 Toyota Corolla at 8629 US Hwy 441. 3 2007 Toyota Corolla at 8629 US Hwy 441. 4 2007 Toyota Camry at 8629 US Hwy 441. 5 Venza Toyota at affordable price 6 Rav4 Toyota 4WD and so on a user is given an input field to type a search keyword. Let's say he types "toyota". Now all i want to do is return a record with two words in it, one word being toyota and another being a word that comes before or after toyota. So results should be like this, Toyota Tundra, Toyota Corolla, Toyota Camry, Venza Toyota, Rav4 Toyota Excluding other words from the returned database field. HOw can this be performed? Any help would be appreciated. Thanks Sabin Quote Link to comment https://forums.phpfreaks.com/topic/234736-extract-words-from-a-returned-recordset-and-return-it/ Share on other sites More sharing options...
Barand Posted April 26, 2011 Share Posted April 26, 2011 Why not put Make, Model columns in your table? Quote Link to comment https://forums.phpfreaks.com/topic/234736-extract-words-from-a-returned-recordset-and-return-it/#findComment-1206351 Share on other sites More sharing options...
Muddy_Funster Posted April 26, 2011 Share Posted April 26, 2011 You will be best to follow Brands suggestion, otherwise you are going to need a huge amount of contional code to extract what you are looking for. Another reason would be that the table is clearly not designed properly if that is how the information is stored and what you are wanting to retrieve from it. Quote Link to comment https://forums.phpfreaks.com/topic/234736-extract-words-from-a-returned-recordset-and-return-it/#findComment-1206365 Share on other sites More sharing options...
watsmyname Posted April 28, 2011 Author Share Posted April 28, 2011 well thanks for the reply These are the example of autos only, there could be restaurant related items, clothings, etc. All i want to do is search in title and extract words like Toyota Corolla, Sony Erricsson, Calvin Klein, etc and discard other words from the title row returned. The tables are not specific to vehicles. This can be achieved via PHP i know, but i have to do it in MySQL. Thanks. watsmyname Quote Link to comment https://forums.phpfreaks.com/topic/234736-extract-words-from-a-returned-recordset-and-return-it/#findComment-1207361 Share on other sites More sharing options...
fenway Posted April 30, 2011 Share Posted April 30, 2011 Then put whatever words you want to be searchable in a dedicated column, and use FULLTEXT. Quote Link to comment https://forums.phpfreaks.com/topic/234736-extract-words-from-a-returned-recordset-and-return-it/#findComment-1208718 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.