1- MySQL database
CREATE TABLE media (
Tittel_ID int(11) NOT NULL auto_increment,
Tittel text NOT NULL,
Medium text NOT NULL,
Sokord text NOT NULL,
PRIMARY KEY (Tittel_ID)
) TYPE=MyISAM AUTO_INCREMENT=154 ;
I inserted a record for example
Tittel_ID :Insert automatic
Tittel :Around the world in 80 days
Medium : DVD
Sokord: action, movie, adult movie, good story, comedy, adventure, love story, funny
===========================================
2- Search form: sok_stikkord.php
<form name="form1" method="post" action="sok_stikkord.php">
Søker på stikkord: f.eks.: <br>
<input type="text" name="sok_stikkord" value="Nature">
<input type="submit" name="Submit" value="Search">
</form>
When I search a word "action" from Sokord database field
3- Search form action: sok_stikkord_action.php
<?php
include("dbconnect.php");
$search=$_POST["sok_stikkord"];
if(!$search)
{
echo("Tast inn one search <a href='sok_stikkord_link.php'>Try again</a>");
}
else
{
$result=mysql_query("SELECT Sokord FROM media WHERE Sokord LIKE '%$search%'");
I DID TRY THESE STRINGS: REGEXP '(|\s)$search($|\s)'
REGEXP '(| )$search(\$| )'
#'\s+$search\s+'
if(mysql_num_rows($result) <= 0)
{
echo (mysql_num_rows($result))." Match. <a href='sok_stikkord_link.php'>Try again</a><br> ";
}
else
{
echo (mysql_num_rows($result))." Match<br>";
}
while($r=mysql_fetch_array($result))
{
$Sokord=$r["Sokord"];
echo "<a href='sok.php?sok=$Sokord'>[ $Sokord ] </a><br>";
}
}
?>
It will display:
1 match
action, movie, adult movie, good story, comedy, adventure, love story, funny
(I GOT PROBLEM HERE)
I want it to display only the whole word "action", Not the whole line from Sokord database field
==========================================
4- Click on the word "action" for more details about the movie
sok.php
<?php
include"dbconnect.php";
if($_SESSION['brukernavn']=true)
$sok=$_GET["sok"];
$result=mysql_query("SELECT *FROM media WHERE Sokord = '$sok'");
while($r=mysql_fetch_array($result))
{
$Tittel=$r["Tittel"];
$Medium=$r["Medium"];
$Sokord=$r["Sokord"];
echo "<b>Tittel:</b>$Tittel<br><b>Medium:</b>$Medium<br>
<b>Sokord:</b>$Sokord<br>
}
mysql_query($result);
?>
So I got problem to search and display the exactly word.
Hope you can solve the problem. Thanks