hey guys,
I'm just wondering how you can link to another set of results within the original search results. For example with my code it displays a table and in one of the coloums, plot number, there is a list of number. I would know what to do once the user clicks it to find the result but what I am wondering is how to make each number in that coloum a link. And once the user clicks the link how do you make that a search variable? I'm pretty new to php so bare with me haha.

<?php
    mysql_connect ("localhost", "root","root") or die (mysql_error());
    mysql_select_db ("FHSNL");
	//sets all values in form to php variables
    $surname = $_POST['surname'];
    $given = $_POST['given'];
	$maiden = $_POST['maiden'];
	$deathdate = $_POST['death'];
	$deathbefore = $_POST['death'] - 5;
	$deathafter = $_POST['death'] + 5;
	$age = $_POST['age'];
	$birth = $_POST['birth'];
	$birthplace = $_POST['birthplace'];
	$deathplace = $_POST['deathplace'];
	$erected = $_POST['erected'];
	$region = $_POST['region'];
	$religion = $_POST['religion'];
	//divides into smaller sql pieces for filled in form input.
	if($surname)$piece[] .= "`SURNAME` LIKE '%$surname%'";
	if($given)$piece[] .= "`GIVEN` LIKE '%$given%'";
	if($maiden)$piece[] .= "`MAIDEN` LIKE '%$maiden%'";
	if($age)$piece[] .= "`AGE` LIKE '%$age%'";
	if($deathplace)$piece[] .= "`PLACE_OF_DEATH` LIKE '%$deathplace%'";
	if($region)$piece[] .= "`TOWN` LIKE '%$region%'";
	if($religion)$piece[] .= "`RELIGION` LIKE '%$religion%'";
	if($deathdate)$piece[] .= "`YEAR_OF_DEATH` BETWEEN '$deathbefore' AND '$deathafter'";
	//if submit button is pressed it runs the search query.
    if(isset($_POST['submit'])){
		if(isset($piece)){
  $sqlend = implode(" AND ",$piece);
  $sql = mysql_query("SELECT * FROM `HEADSTONESA` WHERE $sqlend");
  $rows = mysql_num_rows($sql);
  //constructs the table.
	echo "<table><tr><th>ID</th><th>Given</th><th>Surname</th><th>Cemetery</th><th>Region</th><th>Town</th><th>Date of Death</th><th>Age</th><th>Date of Birth</th><th>Place of Birth</th><th>Place of Death</th><th>Erected By</th><th>Additional Info</th>";
	while($row = mysql_fetch_array($sql))
	{
		echo "<tr>";
    echo "<td>" .$row['ID'] . "</td>";
    echo "<td>".$row['GIVEN']."</td>";
    echo "<td>".$row['SURNAME']."</td>";
	$requested_id = $row['KEYS'];
	$town_id = $row['TOWN'];
	$region_id = $row['REGION'];
	$sql2 = mysql_query("SELECT * FROM `CEMETERIES` WHERE `KEYS` LIKE '$requested_id'");
	$row2 = mysql_fetch_array($sql2);
	echo "<td>".$row2['NAME']."</td>";
	echo "<td>".$row2['REGION']."</>";
	echo "<td>".$row2['TOWN']."</td>";
    echo "<td>".$row['D_OF_DEATH']."</td>";
    echo "<td>" .$row['AGE']. "</td>";
	echo "<td>" .$row['D_OF_BIRTH']."</td>";
	echo "<td>" .$row['PLACE_OF_BIRTH']."</td>";
	echo "<td>" .$row['PLACE_OF_DEATH']."</td>";
	echo "<td>" .$row['ERECTED_BY']."</td>";
	echo "<td>" .$row['ADD_INFO']."</td>";
	echo "</tr>";
		
	}
	echo "</table>";
	//if nothing found prints out the following.
    if(!$rows)
    echo "No results where found";
	
    }
}
//if no search terms entered prints the following.
else{
  echo "You must enter valid search terms";
}
    
    
    ?>

Thanks for the help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.