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.
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!
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:
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/
Damon Edis - interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Damon] Displaying uploads on events page
By jab788 - February 24, 2010
Hey thank you for taking the time to help. Still can't figure this out! Here's my code:
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
require_once "/home2/pittbull/public_html/warmemorial/cmsAdmin/lib/viewer_functions.php";
list($eventsRecords, $eventsMetaData) = getRecords(array(
'tableName' => 'events',
));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style type="text/css">
body { font-family: arial; }
.instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
</style>
</head>
<body>
<!-- INSTRUCTIONS -->
<div class="instructions">
<b>Sample List Viewer - Instructions:</b>
<ol>
<?php ?>
<li><b>Remove any fields you don't want displayed.</b> (Most list pages only have title and link fields.)</li>
<li>Rearrange remaining fields to suit your needs.</li>
<li>Copy and paste code into previously designed page (or add design to this page).</li>
</ol>
</div>
<!-- /INSTRUCTIONS -->
<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<h1>Events - List Page Viewer</h1>
<?php foreach ($eventsRecords as $record): ?>
Record Number: <?php echo $record['num'] ?><br/>
Title: <?php echo $record['title'] ?><br/>
Date: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?><br/>
<!-- For date formatting codes see: http://www.php.net/date -->
Content: <?php echo $record['content'] ?><br/>
Ticketmaster Link: <?php echo $record['evt_ticket'] ?><br/>
Venue: <?php echo $record['evt_venue'] ?><br/>
Month: <?php echo $record['evt_mo'] ?><br/>
Day: <?php echo $record['evt_day'] ?><br/>
Year: <?php echo $record['evt_yr'] ?><br/>
Time: <?php echo $record['evt_time'] ?><br/>
_link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>
<!-- STEP 2a: Display Uploads for field 'img' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
<?php foreach ($record['img'] 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 elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>
<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>
<?php endif ?>
<?php endforeach ?>
<!-- STEP2a: /Display Uploads -->
<hr/>
<?php endforeach ?>
<?php if (!$eventsRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->
</body>
</html>
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.
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
interactivetools.com