Thanks. Yes, here is the script.
<?php
$key=$_POST['key'];
echo $key . '<br><br>';
$num=0;
$user="xsxxxxxxx";
$password="xxxxxxxx";
$database="xxxxxxxx";
$search_company=$_POST['company'];
$search_classification=$_POST['classification'];
mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die("Unable to select database");
// get data - classification only (clicked link from results not found list)
if ((isset($_GET['classification'])) && ($_GET['classification']!=''))
{
$search_classification=$_GET['classification'];
mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die("Unable to select database");
$query="SELECT * FROM contacts WHERE (classification='$search_classification') ORDER BY company ASC";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
}
else
// post data
{
// both classification and company
if (($search_classification != "") && ($search_company != ""))
{
$query="SELECT * FROM contacts WHERE (company LIKE '$search_company%') or (classification LIKE '$search_classification%') ORDER BY company ASC";
}
// classification only
if (($search_classification != "") && ($search_company == ""))
{
$query="SELECT * FROM contacts WHERE (classification LIKE '$search_classification%') ORDER BY company ASC";
}
// company only
if (($search_classification == "") && ($search_company != ""))
{
$query="SELECT * FROM contacts WHERE (company LIKE '$search_company%') ORDER BY company ASC";
}
// run the query
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
}
// results found
if ($num!==0)
{
// results header
echo '<h2>' . $num . ' results for ';
// both classification and company
if (($search_classification != "") && ($search_company != ""))
{echo 'classification "' . $search_classification . '" and company "' . $search_company . '" :</h2>';}
// classification only
if (($search_classification != "") && ($search_company == ""))
{echo 'classification "' . $search_classification . '" :</h2>';}
// company only
if (($search_classification == "") && ($search_company != ""))
{echo 'company "' . $search_company . '" :</h2>';}
// results list
echo '<hr>';
$i=0;
while ($i < $num)
{
// get the results
$id=mysql_result($result,$i,"contactID");
$company=mysql_result($result,$i,"company");
$address=mysql_result($result,$i,"address");
$phone=mysql_result($result,$i,"phone");
$classification=mysql_result($result,$i,"classification");
$website=mysql_result($result,$i,"website");
// display the results
echo
'id: ' . $id . '<br>
company: ' . $company . '<br>
address: ' . $address . '<br>
phone: ' . $phone . '<br>
classification: ' . $classification . '<br>
<a href="http://' . $website . '">http://' . $website . '</a><br><br>
open within frame:<br>
<a href="frame.php?website=' . $website .'" target="_blank">' . $website . '</a><br><br>
<input type="Submit" value="details">
<input type="hidden" name="key" value="' . $id . '"><br>
<hr>
';
$i++;
}
}
else
{
// no results found
echo
'<h2>Sorry! No Results Found. Please Select from one of the following Classifications</h2>
<a href="results.php?classification=supermarket">Supermarket</a><br>
<a href="results.php?classification=department store">Department Store<br></a>
<a href="results.php?classification=designers">Designers</a>
';
}
?>
The bit where I'm getting the hidden ID field is in the section headed "// display the results".
Where I'm picking it up is right at the beginning.
Okay, I know I'm not doing anything with this field at the moment, apart from print it out, but I'll add that stuff once I know I'm getting the right data.