Event Calendar with Images Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kingdeejay
Forum Newbie
Posts: 4
Joined: Sat Feb 06, 2010 11:40 pm

Event Calendar with Images Problem

Post by kingdeejay »

I am making an event calendar similar to the one found here: http://www.furnightclub.com/calendar.php .
I already have the calendar created, but I am having problems with getting images to load into the calendar. I want to query the database for a date and pull the image into the calendar where the event date is equal to the calendar date. I can't figure out how to have the images display and when they are clicked they go to a page with the full image and description. Please help with this thanks.
limitdesigns
Forum Commoner
Posts: 25
Joined: Sat Feb 06, 2010 9:05 pm

Re: Event Calendar with Images Problem

Post by limitdesigns »

Do you have any code we can work with? It's kind of hard to help when we don't know what you've already tried.
kingdeejay
Forum Newbie
Posts: 4
Joined: Sat Feb 06, 2010 11:40 pm

Re: Event Calendar with Images Problem

Post by kingdeejay »

Code: Select all

/** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !!  IF MATCHES FOUND, PRINT THEM !! **/
                 $this->calendar.= '<div class="'. $this->style .'-text">
 
/*this is the area where I need to add code to query the database.  My sql code would be something like
   SELECT EVT_THUMB, EVT_FULLFLYER, EVT_DESC FROM EVENT WHERE EVT_DATE = SYSDATE;
 
 
  I want the thumnail to show in the calendar and when you click on it, it will take you to another page that has the full flyer and description on it.
*/
 
</div><br/>';
                 </div>';
                 $this->calendar.= str_repeat('<p> </p>',2);
limitdesigns
Forum Commoner
Posts: 25
Joined: Sat Feb 06, 2010 9:05 pm

Re: Event Calendar with Images Problem

Post by limitdesigns »

So you could do something like this:

Code: Select all

 
<?php
$array = mysql_query("SELECT `EVT_THUMB`, `EVT_DESC` FROM `EVENT` WHERE `EVT_DATE`= CURDATE()");
$thumb = $array['EVT_THUMB'];
$page_url = _________;
?>
<a href="<?php echo $page_url;?>"><img src="<?php echo $thumb;?>" alt="Event"/></a>
 
You would also need to get the row ID of that specific event, and pass it to the next page with a GET request. Let's say you call that variable "ID" in your request, so on your event page you would do:

Code: Select all

 
<?php
$id = $_GET['ID'];
$array = mysql_query("SELECT `EVT_FULLFLYER` FROM `EVENT` WHERE `EVT_ID`= '$id'");
$full = $array['EVT_FULLFLYER'];
?>
<img src="<?php echo $full;?>" alt="full flyer"/>
 
kingdeejay
Forum Newbie
Posts: 4
Joined: Sat Feb 06, 2010 11:40 pm

Re: Event Calendar with Images Problem

Post by kingdeejay »

So Evt_ID would be my primary key from my database, so what would the $_GET ID be?

Also do I load the images directly in my database or can I save them in a folder and call them from a path? I was thinking that my evt_fullflyer would a a varchar field and I would call the path where the jpg was located.

Thank you very much for all your help.
kingdeejay
Forum Newbie
Posts: 4
Joined: Sat Feb 06, 2010 11:40 pm

Re: Event Calendar with Images Problem

Post by kingdeejay »

Code: Select all

/** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !!  IF MATCHES FOUND, PRINT THEM !! **/
                  require (connect.php);
                 $this->calendar.= '<div class="'. $this->style .'-text">
                 
                 $array = mysql_query("SELECT `EVT_THUMB`, `EVT_DESC` FROM `EVENT` WHERE `EVT_DATE`= CURDATE()");
                 $thumb = $array['EVT_THUMB'];
                 $page_url = "http://www.mywebsite.com/events.php";
                 
                 
                 <a href="<?php echo $page_url;?>"><img src="<?php echo $thumb;?>" alt="Event"/></a></div>';
                 
                 
                 $id = $_GET['EVT_NUM'];
                 $array = mysql_query("SELECT `EVT_FULLFLYER` FROM `EVENT` WHERE `EVT_NUM`= '$id'");
                 $full = $array['EVT_FULLFLYER'];
                
                 <img src="<?php echo $full;?>" alt="full flyer"/>
                 
                 $this->calendar.= str_repeat('<p> </p>',2);
               
I changed the $id variable to get evt_num because that is the id or primary key in my database. Would I have to put the open and close php tags that are used in the anchor tags? This is in a class.
limitdesigns
Forum Commoner
Posts: 25
Joined: Sat Feb 06, 2010 9:05 pm

Re: Event Calendar with Images Problem

Post by limitdesigns »

The GET method would pass the value of evt_num to the next page, from which you can do another query to get the full flyer, etc. There's a problem in the code you posted, though...mysql_query() returns a mysql object. You have to THEN use mysql_fetch_array() or mysql_fetch_row() to get the code. So if you have $array = mysql_query(your_query), you have to add $array = mysql_fetch_array($array), and then you can say $full = $array['EVT_FULL_FLYER'];
Post Reply