hansman Posted July 8, 2008 Share Posted July 8, 2008 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 More sharing options...
DeanWhitehouse Posted July 8, 2008 Share Posted July 8, 2008 using the GET method or the POST method. Link to comment https://forums.phpfreaks.com/topic/113765-sending-data-through-header/#findComment-584622 Share on other sites More sharing options...
hansman Posted July 8, 2008 Author Share Posted July 8, 2008 i am using $table = $_GET['table']; on outcomes.php i have set $table = Lawn_Pest on lawn.php then in outcomes.php i use SELECT * FROM $table etc Link to comment https://forums.phpfreaks.com/topic/113765-sending-data-through-header/#findComment-584627 Share on other sites More sharing options...
DeanWhitehouse Posted July 8, 2008 Share Posted July 8, 2008 ok, so? Link to comment https://forums.phpfreaks.com/topic/113765-sending-data-through-header/#findComment-584642 Share on other sites More sharing options...
hansman Posted July 8, 2008 Author Share Posted July 8, 2008 You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ''' WHERE id='1table=Lawn_and_Tree_Pests'' at line 1 Link to comment https://forums.phpfreaks.com/topic/113765-sending-data-through-header/#findComment-584646 Share on other sites More sharing options...
DeanWhitehouse Posted July 8, 2008 Share Posted July 8, 2008 can you post your full code. Link to comment https://forums.phpfreaks.com/topic/113765-sending-data-through-header/#findComment-584791 Share on other sites More sharing options...
hansman Posted July 8, 2008 Author Share Posted July 8, 2008 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');?> Link to comment https://forums.phpfreaks.com/topic/113765-sending-data-through-header/#findComment-584818 Share on other sites More sharing options...
hansman Posted July 9, 2008 Author Share Posted July 9, 2008 any ideas? Link to comment https://forums.phpfreaks.com/topic/113765-sending-data-through-header/#findComment-585246 Share on other sites More sharing options...
DeanWhitehouse Posted July 9, 2008 Share Posted July 9, 2008 erm, whats the url? Link to comment https://forums.phpfreaks.com/topic/113765-sending-data-through-header/#findComment-585654 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.