I or a form search
If only 1 result and I would do a redirect to details page.
In my form, or this error
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\a1\a2\a.php:9) in C:\xampp\htdocs\a1\a2\a.php on line 32
............................................................
<?php
$search = $_GET['q'];
if(strlen($search)<=3)
echo "Search term too short";
else{
echo "You searched for <b>$search</b> <hr size='1'></br>";
mysql_connect("localhost","ciao","ciao");
mysql_select_db("ciao");
$search_exploded = explode (" ", $search);
foreach($search_exploded as $search_each)
{
$x++;
if($x==1)
$construct .="keywords LIKE '%$search_each%'";
else
$construct .="AND keywords LIKE '%$search_each%'";
}
$construct ="SELECT * FROM ciao WHERE $construct";
$run = mysql_query($construct);
$foundnum = mysql_num_rows($run);
if ($foundnum==1){
header("location: http://localhost/a1/a2/go);
}
else
{
echo "$foundnum results found !<p>";
while($runrows = mysql_fetch_assoc($run))
{
$title = $runrows ['title'];
$desc = $runrows ['description'];
$url = $runrows ['url'];
echo "
<a href='$url'><b>$title</b></a><br>
$desc<br>
";
}
}
}
?>
......................................
Appearance reply
Regards