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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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