Hi, this script wont show the result from my data base, might be here
if ($x==1)
$construct .= " description LIKE '%$search_each%'";
else
$construct .= " AND description LIKE '%$search_each%'";
i tried to change the description to another column like location but no luck.
<?php
include ('connect.php');
$button = $_GET['submit'];
$search = $_GET['search'];
if (!button)
echo "you didnt submit a keyword.";
else
{
if (strlen($search)<=2)
echo "search term to short.";
else
{
echo " You searched for <b>$search</b><hr size='1'>";
//connect to our database
$search_exploded = explode(" ",$search);
foreach($search_exploded as $search_each)
{
// construct query
$x++;
if ($x==1)
$construct .= " description LIKE '%$search_each%'";
else
$construct .= " AND description LIKE '%$search_each%'";
}
// echo out construct
$construct = "SELECT * FROM flats WHERE $construct";
$run = mysql_query($construct);
$foundnum = mysql_num_rows($run);
if (foundnum==0)
echo "No results found.";
else
{
echo "$foundnum result found!<p>";
while ($runrows = mysql_fetch_assoc($run))
{
// get data
$select = $runrows['type'];
$title = $runrows['title'];
$location = $runrows['location'];
echo "
echo $title;
echo <br>;
echo $select;
echo <br>;
echo $rent;
echo <br>;
echo $location;
echo <hr>";
}
}
}
}
?>
search engine script not showing result
Moderator: General Moderators
-
balamberas
- Forum Newbie
- Posts: 10
- Joined: Fri Mar 06, 2009 12:36 pm
Re: search engine script not showing result
Hi balamberas !
You can debug this by executing your query directly in mysql when it is done after this:
$construct = "SELECT * FROM flats WHERE $construct";
give to your self one echo of this $construct to see it.
If your mysql return zero rows - evertything is ok with mysql, but there is not such result in your data base.
You can debug this by executing your query directly in mysql when it is done after this:
$construct = "SELECT * FROM flats WHERE $construct";
give to your self one echo of this $construct to see it.
If your mysql return zero rows - evertything is ok with mysql, but there is not such result in your data base.
-
balamberas
- Forum Newbie
- Posts: 10
- Joined: Fri Mar 06, 2009 12:36 pm
Re: search engine script not showing result
Hi,
sorry but i dont know the right syntax to use in able to see what the errors are. I did SELECT * FROM table_name and got the results from my database table.
sorry but i dont know the right syntax to use in able to see what the errors are. I did SELECT * FROM table_name and got the results from my database table.