Hi Nathj. You help seems to be really workng now. Thanks for that. I've managed to run the cose but now:
As i run the code it says:
Quote:
Notice: Undefined index: searchtext in C:\Apache2\WWW\localhost\search1.php on line 7
and when i refresh the page, it displays:
Quote:
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Seems as if i'm so near yet so far.Here goes the code.
[PHP]<?php
include "dbconnect.php";
// The basic SELECT statement
$select = 'SELECT DISTINCT pcode,purl ';
$from = ' FROM product';
$where = ' WHERE 1=1 ';
$searchtxt = $_POST['searchtext'];
if ($searchtxt != '')
{ // Some search text was specified
$where .= " AND pcode LIKE '%$searchtxt%'";
}
?>
// execute the query
<?php
$url = mysql_query($select . $from . $where);
// test the result
if (!$url)
{
exit('<p>Error retrieving urls from database!<br />'.
'Error: ' . mysql_error() . '</p>');
echo '<p> no product found</p>' ;
}
while ($lcurl = mysql_fetch_array($url))
{
$id = $lcurl['pcode'];
$pdurl = htmlspecialchars($lcurl['purl']);
header("Location:$pdurl");
}
?>[/PHP]
I think the problem area is this part of the code:
[PHP]$searchtxt = $_POST['searchtext'];
if ($searchtxt != '')
{ // Some search text was specified
$where .= " AND pcode LIKE '%$searchtxt%'";
}[/PHP]
Any suggestions?