Forum Moderators: coopster
I'm practicing to understand and learn and have the following example. My page displays the state with the pet names under them, like this:
CA
Fido, Bowser,
FL
Kittycat, Red, Bones,
etc.
When the names are clicked, it presents a page like [domain...]
What I don't understand is how to make it so that when the name is clicked, it actually opens up to a formatted page, such as
(the values are in a mysql database)
At this point I get a page not found. I've looked for tutorials that might give me a clue how to achieve that, but haven't had any luck so am appealing to someone here who might be able to help me understand that concept.
Up to now I have been able to create a simple content management system on my other test pages, yet I just don't understand how to make a "real" page that shows the pet's name is clicked.
Here's the code so far for the memorials listings page:
<?php
$petID=$_POST['petID'];
// Connect to the database
require_once ('../Connections/mysql_connect.php');
// Get data
$states = "SELECT state FROM users GROUP BY state";
$result = mysql_query($states);
while ($row = mysql_fetch_assoc($result)) {
echo "<p>" . $row["state"] . "<br>\n";
$statename = $row["state"];
$allpets = "SELECT memID, petName FROM users WHERE state='$statename' ORDER BY petName ASC";
$pet = mysql_query($allpets);
while ($pets = mysql_fetch_assoc($pet)) {
echo "<a href='names.php?pet={$pets['memID']}'>{$pets['petName']}</a>, ";
}
}
?>
When I click on a name I get what I expect for a url but I don't have any data there >> I tried adding just this one thing after the end of the php above
<td><?php print $owner?></td> Thanks for any advice or a tutorial that shows a similar sample of how to do that.
Well first of all you'll need to have a names.php file.
The variable you're after will then be in the $_GET array as $_GET['pet'].
Once you've got that then follow the examples in this thread to get the rest of your data.
[webmasterworld.com...]
I created the names.php page and added the following code, but still get a page not found when clicking on the link. I guess I still don't understand how this works.
<?php
// Connect to the database
require_once ('../Connections/mysql_connect.php');
// Get the pet's name
if (isset($_GET[pet])) {
$query = "SELECT owner FROM users WHERE petID ='$petID'";
$result = mysql_query($query);
while ($row = mysql_fetch_array ($result)) {
// display owner information text
echo "$_GET['owner'];"
}
}
?>
What am I doing wrong?