Jump to content

[SOLVED] PHP MYSQL + SEARCH HELP


logicopinion

Recommended Posts

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>";


?>

Link to comment
https://forums.phpfreaks.com/topic/71990-solved-php-mysql-search-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.