rpcob Posted September 17, 2009 Share Posted September 17, 2009 Hello, I don't know what I'm looking for otherwise i would have already searched. I have a site with events that are updated weekly on the main page. I am looking to link the events on the main page to a page with info on that event. On the page i have an iframe. How can i set it up to where the right iframe opens on the page depending on the event they click on from the main page. Or not even use iframes at all and just have it all on the page and have the information show depening on the php id. Thank you. I know nothing about php. Just how to manipulate exisitng code. Quote Link to comment Share on other sites More sharing options...
Psycho Posted September 17, 2009 Share Posted September 17, 2009 Then you will need to learn PHP or some other server-side language. Basically you want to create a page that will get the details of the selected item and output it in a predefined format. You could pass the id of the item on the URL like this: http://mysite.com/getEvent.php?eventID=3 So, when you display the page with all the events listed use the PHP code to create a link for each one with the appropriate ID number. There's more to it than that, of course, but too much to try and explain in a forum post. It's not an exceptionally hard project, though. Start by creating a hard coded page with how the details will be displayed. Then modify the page to get the details from the database and populate the information. Quote Link to comment Share on other sites More sharing options...
rpcob Posted September 17, 2009 Author Share Posted September 17, 2009 http://mysite.com/getEvent.php?eventID=3 So, when you display the page with all the events listed use the PHP code to create a link for each one with the appropriate ID number. That was what i was looking for. Do you have any quick examples to give me for linking the event to loading a specific page in the iframe? Quote Link to comment Share on other sites More sharing options...
Psycho Posted September 17, 2009 Share Posted September 17, 2009 Here's a very rough draft. <?php $eventID = (int) $_GET['eventID']; $query = "SELECT * FROM events WHERE id='{$eventID}'"; $result = mysql_query($query) or die(mysql_error()); if (mysql_num_rows($result)==0) { die("No event matches the id '{$eventID}'"); } $event = mysql_fetch_assoc($result); ?> <html> <head> <title>Event Details</title> </head> <body> <h1>Event name: <?php echo $event['name']; ?></h1> <br> Date: <?php echo $event['date']; ?> Time: <?php echo $event['time']; ?> <br> Description: <?php echo $event['description']; ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
rpcob Posted September 17, 2009 Author Share Posted September 17, 2009 I was looking through the forum... is this something that would work for me? http://www.phpfreaks.com/forums/index.php/topic,269559.0.html Quote Link to comment Share on other sites More sharing options...
kratsg Posted September 17, 2009 Share Posted September 17, 2009 I was looking through the forum... is this something that would work for me? http://www.phpfreaks.com/forums/index.php/topic,269559.0.html A similar idea would work. However, the page you have the iframe load would use coding similar to what mjdamato has provided you. 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.