Jump to content

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');?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.