I posted about this before but I didn't quite seem to get it working.
Below is the code I am using:
Its basically a script I am using to search my site but the problem is it will only display one result when I search for something. I tried using in_array and some other commands but they haven't worked either. For example, in the database there would be a few rows with the word php in them. Lets say there are 2 rows to make it simple. These are:
php
php > tutorials
If the user types in php it will display php but not php > tutorials. I've tried many things to solve this problem and it is driving me mad. I would appreciate any help. Thanks in advance.
Below is the code I am using:
PHP:
<?
include("config.php");
include("common.php");
if($mode == "enter") {
?>
<form action=search.php>
<input type=hidden name=mode value=results>
<table width=100%>
<tr><td><input type=text name=searchtext></td></tr>
<tr><td><input type=submit value=Search></td></tr>
</form>
<?
}
$result = mysql_query("SELECT * FROM arenatopics");
while ($row = mysql_fetch_array($result)) {
if($mode == "results" && eregi($searchtext, $row[Name])) {
?>
<table width=100%>
<tr><td>Page name: <a href=view.php?ID=<? echo $row[ID]; ?>><font><? echo $row[Name]; ?></font></a></td></tr>
</table>
<?
exit;
}
}
if(eregi($searchtext, $row[Name]) !== $searchtext) {
echo "No results were found.";
}
?>
Its basically a script I am using to search my site but the problem is it will only display one result when I search for something. I tried using in_array and some other commands but they haven't worked either. For example, in the database there would be a few rows with the word php in them. Lets say there are 2 rows to make it simple. These are:
php
php > tutorials
If the user types in php it will display php but not php > tutorials. I've tried many things to solve this problem and it is driving me mad. I would appreciate any help. Thanks in advance.