amk Posted March 18, 2018 Share Posted March 18, 2018 Hello, I am trying to create a scripts that takes the user input. For example, a text and searches every word from the text in an already created database. Then the same text is displayed and the words are coloured based on their rank. Up till now this is what i have: <?php $query=$_GET['query']; if (isset($_GET['submit'])){ //$result1=$_GET['query']; $words = explode(' ', $query); $queryDB ="SELECT `Word` FROM `WordFrequencyList` WHERE "; $conds = array(); foreach ($words as $val) { $conds[] = "WordFrequencyList.Word LIKE '".$val."'"; } $queryDB .= implode(" ", $conds); $final=mysql_execute($queryDB); ?> The code only separates the text into words. How can i fetch these words from the database after the text has been separated into words? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 18, 2018 Share Posted March 18, 2018 Not sure what you mean by your last point. The code seems to be building a query statement almost perfectly. Your only problem is when you do your implode you need to add " and " instead of just the space. Also - you really need to STOP using the MySQL functions. They are deprecated. See the manual. Switch to mysqlI or better yet to PDO. 1 Quote Link to comment 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.