Jump to content

sending data through header


hansman

Recommended Posts

hello i have a page called lawn.php which reads from the Lawn_Pest table in the database.

 

I want to have one page called "outcomes.php"

 

i have other pages like lawn.php that connect to different tables, i want to have them all intertwined with outcomes.php

 

how can i send the Lawn_Pest name to the sql query at outcomes.php so when the user gets to outcomes.php from lawn.php, they will only see results from Lawn_Pest

 

 

Link to comment
https://forums.phpfreaks.com/topic/113765-sending-data-through-header/
Share on other sites

 

 

lawn.php

<?php include_once('header.php');?>
<?php include_once('sidenav.php');?>
  <div id="content">
    <div id="content2">
      <h2>Lawn Pests</h2>
      <p>Please select a pest that is most commonly found on you lawn on in your trees.</p>
       <?php 
   
   
$table = "Lawn_and_Tree_Pests";


   

mysql_connect("localhost", "xxxxxx", "xxxx");
mysql_select_db("xxxxx") or die( "Unable to select database"); 


$query = "SELECT Name, id FROM $table"; 

$result = mysql_query($query) or die(mysql_error());


while($row = mysql_fetch_array($result)){
echo "<h2><a href=\"pest.php?id=".$row['id']."\" />"."-".$row['Name']."</a><br>\n</h2>";

}

?>
    </div>
  </div>

<?php include_once('footer.php');?>

 

 

pest.php


<?php include_once('header.php');?>
<?php include_once('sidenav.php');?>
<?php



$table = $_GET['table'];
$id = $_GET['id'];



mysql_connect("localhost", "xxxxxxx", "xxxxx");
mysql_select_db("xxxxxxxx") or die( "Unable to select database"); 

$query = "SELECT * FROM $table where id ='$id'";

$result = mysql_query($query) or die(mysql_error());


$row = mysql_fetch_array($result)

?>

  <div id="content">
    <div id="content2">
      <h1>Pest: <? echo $row['Name']; ?></h1><br />
      <h3>Habitat: </h3><p><? echo $row['Habitat']; ?></p><br />
      <h3>Behavior: </h3><p><? echo $row['Behavior']; ?></p><br />
         <h3>Color: </h3><p><? echo $row['Color']; ?></p><br />
            <h3>Tips For Control: </h3><p><? echo $row['Tipsforcontrol']; ?></p>
    </div>
  </div>

<?php  include_once('footer.php');?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.