Hi,
Is it possible to post ($_POST) a variable, e.g. ($_POST [$var])?
I have a form on a search page with a drop down list populated from mysql DB. This works fine on the search page, but I want to send the results to another page which queries the same DB and outputs more info. My problem is that I can’t $_POST the results as they are now variables themselves. I assume I have to try extracting the contents of the variable before querying it a second time but am unsure of how to go about this.
Relevant code from Search page:
$query = (“SELECT DISTINCT location FROM monuments ORDER BY location”);
$result = mysqli_query($con, $query);
while ($row = $result->fetch_assoc())
{
$location = $row[‘location’];
echo “<option value=>$location”;
}
Relevant code from Results page:
$recorder= $_POST[‘recorder’];
$type= $_POST[‘type’];
$location= $_POST[‘location’];
$query = (“SELECT * FROM monuments”);
$result = mysqli_query($con, $query);
switch (true)
{
case (!empty($type) && empty($recorder) && empty ($location)):
{
$query = (“SELECT * FROM monuments WHERE type = ‘$type’”);
$result = mysqli_query($con, $query);
echo"Results found for $type";
break;
}
case (empty($type) && empty($recorder) &&empty ($location)):
{
$query = (“SELECT * FROM monuments”);
$result = mysqli_query($con, $query);
echo “Results for all recorded Sites”;
break;
} …
Any help would be greatly appreciated.