Jump to content

Php help


rpcob

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/174606-php-help/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/174606-php-help/#findComment-920202
Share on other sites

  Quote

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?

Link to comment
https://forums.phpfreaks.com/topic/174606-php-help/#findComment-920217
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/174606-php-help/#findComment-920221
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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