Displaying uploads on events page

4 posts by 3 authors in: Forums > CMS Builder
Last Post: February 24, 2010   (RSS)

By jab788 - February 22, 2010

We are developing a website for an organization that hosts concert events. On their "events" page they want a small picture for each event along with the title, date and time of the event.

I have no problem just listing the events, but I'm having a heck of a time getting the event's image to display with its specific listing. I'm still pretty new to PHP, but I always kept the image associated with the record in the same table as the records. With CMS builder it sends all uploaded images to a different table (cms_uploads) and I'm unfamiliar with how to work with that.

We have it set up so the visitor can choose a month and see which events are listed for that month. Here is the code for April.

$result = mysql_query("SELECT * FROM cms_events WHERE evt_mo = 04 ORDER BY evt_day ASC");
$img = mysql_fetch_array($result);
$pic = $img['num'];

$image = mysql_query("SELECT * FROM cms_uploads WHERE tableName = 'events' AND recordNum = '".$pic."'");

$nextRow=1;
echo "<tr>";
while(($row = mysql_fetch_array($result)) && ($pho = mysql_fetch_array($image)))
{
echo "<td class='events2'>" . "<a href='" . $_SERVER['PHP_SELF'] . "?id=" .$row['num'] . "&mode=eventpage'>";
echo "<img src='" . $pho['urlPath'] . "' border='0' width='100' /></a>" . "<br /><br />";
echo "<a href='" . $_SERVER['PHP_SELF'] . "?id=" .$row['num'] . "&mode=eventpage'>" . "<strong>" . $row['title'] . "</strong></a>" . "<br />" . $row['evt_mo'] . "/" . $row['evt_day'] . "/" . $row['evt_yr'] . "<br />" . $row['evt_time'];
echo "</td>";


Am I on the right track? I don't know if I'm even close to doing this right. Any help would be fantastic. Thank you!

Re: [jab788] Displaying uploads on events page

By Damon - February 24, 2010

Hi,

Can you use the Code Generator (Admin > Code Generator) to generate code for your events section and then paste it as a reply?

This way I can see all the fields you have.

Here is a simple example code to output events with a thumbnail image:
<h2>Events</h2>

<table>
<?php foreach ($events_Records as $record): ?>
<tr>
<td>
<?php foreach ($record['image'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>
<?php endif ?>
<?php endforeach ?>
</td>
<td>
<?php echo $record['title'] ?><br/>
<?php echo date("D, M jS, Y", strtotime($record['date'])) ?><br/>
Event details: <?php echo $record['content'] ?><br/>
Etc....
</td>
</tr>
<?php endforeach ?>
</table>

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [jab788] Displaying uploads on events page

By Dave - February 24, 2010

Hi jab788,

It looks right to me. And that's not displaying the images?

Let me know what's happening and I'll try to help.
Dave Edis - Senior Developer
interactivetools.com