logicopinion Posted October 5, 2007 Share Posted October 5, 2007 hello, i have database which stores news. i have for columns in it : 1. id 2. title 3. date 4. full text so, in each row of an id, and date there is only one word, or numbers, and when search by id, or date, php can easily find exact match. but if i want to search a word which is stored in column "full text" (some sentance forexample) and the middle word is "seachword" or even if the word is in the beggining or at the and of the sentance, and i use it for search php give 0 results. why does it happen? do i miss something? here is the whole code: <?php $keyword = $_POST['keyword']; mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("mynews") or die(mysql_error()); $query = "SELECT * FROM newsdb WHERE date='$keyword' or title='$keyword' or rte1='$keyword'"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) echo $row['rte1']; print "<br>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/71990-solved-php-mysql-search-help/ Share on other sites More sharing options...
logicopinion Posted October 5, 2007 Author Share Posted October 5, 2007 please someone say something .. Quote Link to comment https://forums.phpfreaks.com/topic/71990-solved-php-mysql-search-help/#findComment-362695 Share on other sites More sharing options...
teng84 Posted October 5, 2007 Share Posted October 5, 2007 $query = "SELECT * FROM newsdb WHERE date like '%$keyword%' or title like '%$keyword%' or rte1 like '%$keyword%'"; Quote Link to comment https://forums.phpfreaks.com/topic/71990-solved-php-mysql-search-help/#findComment-362952 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.