Meekay Posted March 14, 2007 Share Posted March 14, 2007 I'm creating a simple master/details 2 page setup. The first page has a list of names and photos, and the second reveals the details for that person. I've added this on the master page... <a href="actor_detail.php?recordID=<?php echo $row_actorslist['submission_id']; ?>"><?php echo $row_actorslist['name']; ?></a> So the user is taken to the actor_detail.php page and the 'submission_id' value is carried in the url (i think). Then on the detail page i have... <?php require_once('Connections/actors.php'); ?> <?php mysql_select_db($database_actors, $actors); $query_actordetail = "SELECT * FROM ft_form_1"; $actordetail = mysql_query($query_actordetail, $actors) or die(mysql_error()); $row_actordetail = mysql_fetch_assoc($actordetail); $totalRows_actordetail = mysql_num_rows($actordetail); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php echo $row_actordetail['submission_id']; ?> <?php echo $row_actordetail['name']; ?> <?php echo $row_actordetail['email']; ?> <?php echo $row_actordetail['age']; ?> <?php echo $row_actordetail['eyes']; ?> <?php echo $row_actordetail['hair']; ?> <?php echo $row_actordetail['accents']; ?> <?php echo $row_actordetail['training']; ?> </body> </html> <?php mysql_free_result($actordetail); ?> I just need to know how to link the value in the url to this page, so it displays the record with that ID. Pleeeeeeeeeeeeeeease... Thanks, Quote Link to comment Share on other sites More sharing options...
aebstract Posted March 14, 2007 Share Posted March 14, 2007 Something like: <a href=actor_detail.php?profile=$row_actorslist['submission_id'];>Person</a> Then on your other page you will have something like: $profile = $_GET['profile']; That sets $profile to your $row_actorslist['submission_id'] which should be in your url. Then use that variable to do whatever you need that id for. Quote Link to comment Share on other sites More sharing options...
papaface Posted March 14, 2007 Share Posted March 14, 2007 But before putting it into a SQL statement make sure you mysql_real_escape_string() it. Quote Link to comment Share on other sites More sharing options...
Meekay Posted March 14, 2007 Author Share Posted March 14, 2007 Ok, i'm lost... I just need to run a query based on recordID (the parameter passed in the url)... I just assumed it was some kind of select query filtered by recordID. Forgive me for my noobesence. Quote Link to comment Share on other sites More sharing options...
aebstract Posted March 14, 2007 Share Posted March 14, 2007 You said when you click on a name/photo you want it to take you to another page where it displays the information for that person, correct? If so, you need to do what I posted above to achieve this. This way you pass the id for the person chosen to the next page and then grab that value out of the url so that you can take out the information in the database that matches that id. Make sense? Quote Link to comment Share on other sites More sharing options...
Meekay Posted March 14, 2007 Author Share Posted March 14, 2007 It's not that it doesn't make sense. I just don't know how to apply it. I'm out of my depth. Thanks anyway fella. Quote Link to comment Share on other sites More sharing options...
Meekay Posted March 14, 2007 Author Share Posted March 14, 2007 I already have this <td><a href="actor_detail.php?recordID=<?php echo $row_actorslist['submission_id']; ?>"><?php echo $row_actorslist['name']; ?></a></td> Which i'm almost certain will put the 'submission_id' value into a url parameter called 'recordID'... It confuses me that you want to change this part of the code. Could you tell me simply (in code) how to call that parameter on the details page and then run a query based on it that will bring up the values for that one record... My apologies if i'm being infuriating. Quote Link to comment Share on other sites More sharing options...
aebstract Posted March 14, 2007 Share Posted March 14, 2007 $recordID= $_GET['recordID']; This sets a variable called $recordID to that id that you passed in the url Then you run a query kinda like: SELECT * FROM tablename WHERE (recordID=$recordID) Does that make more sense to you than the previous? Quote Link to comment Share on other sites More sharing options...
Meekay Posted March 14, 2007 Author Share Posted March 14, 2007 Yes! That's wonderful, thank you for your patience. Quote Link to comment Share on other sites More sharing options...
aebstract Posted March 14, 2007 Share Posted March 14, 2007 Good luck with your site Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.