Web Development

General discussion


Using mysql for search engines

By poeziile12 ·
Using mysql, can i build a good search engine for my site: http://www.poeziile.com ?
I have a problem. In Romanian language we use some diacritics and i can't store them in mysql database. Or maybe i'm wrong so please correct me. Some links where you can see my site with diacritics:

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

Yes ofcourse you can..

by spotlightnight In reply to Using mysql for search en ...

Lets say that you would search in a table called: news and a column called newscontent. You would have to do something like that:

Let's say that phrase that you are searching for is in variable called $phrase

$query = "SELECT * from `news` WHERE newscontent LIKE '%$phrase%'";
$result = mysql_query($query);
while ( $row = mysql_fetch_assoc($result)) {

$titleofnews = $row['title']; // I dont know exacly in what column you store a title of news.
$content = $row['newscontent'];

$found = $found.'<h2>'.$titleofnews.'</h2><br>'.$row['newscontent'];

if (!empty($found))
echo $found;
echo 'The phrase that you were searching for was not found. Sorry.';

This is just an example.


Collapse -

o solutie

by jtherapist In reply to Using mysql for search en ...

eu trebuia sa salvez in baza de date caractere rusesti am facut un set de cereri pe care le-am pus in scriptul care realiza conexiunea la baza de date mysql. Vezi sa ai collation la campul in care salvezi info utf8

mysql_query("SET NAMES utf8");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET character_set_connection = utf8");

Related Discussions

Related Forums