I currently have a php file displaying a list of unique VARCHAR items in a table on a SQL server like this:
echo "<b><center>Strain List</center></b><br><br>";
$i=0;
$priorstrain='NULL';
while ($i < $num) {
$strain=mysql_result($result,$i,"Strain");
if ($strain!=$priorstrain) {
echo "<a href=result.php><b>$strain</b></a>";
}
$priorstrain=$strain;
$i++;
}
I would like all items that matches $strain to display on the next page. For example, say the list displays:
CAT DOG MOUSE
and when someone clicks on DOG I want the page to redirect to a page that shows:
STRAIN OWNER DOB COLOR
DOG JOHN 9/9/2015 BROWN
DOG JEFF 10/04/2013 BLACK
What is the best way to accomplish this?
Thanks in advance!
</div>
You can use GET variables as @bassxzero said, to do this you can do like this in your code :-
if ($strain!=$priorstrain) {
echo "<a href='result.php?strain='$strain><b>$strain</b></a>";
}
result.php
if(isset($_GET['strain'])) {
//I am not doing but make sure you validate this variable first :)
$stname = $_GET['strain'];
//SOME CODE HERE LIKE
// SELECT QUERY TO SHOW ALL RESULT LIKE OWNER'S NAME, DETAILS, ETC.
}
Hope this will help you :)