Getting Upload to Background Image

2 posts by 2 authors in: Forums > CMS Builder
Last Post: March 11, 2008   (RSS)

By Mohaukla - March 11, 2008

I would like to have a client just upload a picture and have that image appear as the background in a table cell.

I have the page to look at here. http://www.efreewillmar.org/youth3.php

The image is above the table now.

The code looks like this
<body>
<?php
require_once "C:/Webspace/resadmin/mmoyers/efreewillmar.org/www/cmsAdmin/lib/viewer_functions.php";
$options = array(); // NOTE: see online documentation for more details on these options
$options['tableName'] = 'about_us_001'; // (REQUIRED) MySQL tablename to list record from. Example: "article";
$options['recordNum'] = ''; // (optional) Record number to display. Example: "1"; Defaults to number on end of url, then 1
$options['where'] = ''; // (ADVANCED) MySQL WHERE conditions to use INSTEAD of recordNum to look up record. Example: "fieldname = 'value'"
$record = getRecord($options);
?>
<?php if ($record): ?>
<?php foreach (getUploads($options['tableName'], 'images', $record['num']) as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" />
<?php endif ?>
<?php endforeach ?>
<?php endif ?>
<br/>
<table width="171" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="80" background="">&nbsp;</td>
<td width="91">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>

</body>


When I have tried to pull in all or parts of the php into the "TD" tag it ends up not working.
Is this possible and how?

Thanks
Michael Moyers



Owner of Just Rite Design Inc. A growing network of professionals in web design, graphic design, flash development, programming, and audio & video productions.



"Due to budget constraints, the Light at the end of the tunnel will be temporarily out!"

Re: [justritedesign] Getting Upload to Background Image

By Dave - March 11, 2008

Try this after the first code block with options and getRecord().

...
$record = getRecord($options);
$uploads = getUploads($options['tableName'], 'images', $record['num']);
?>

<br/>
<table width="171" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="80" background="<?php echo $uploads[0]['thumbUrlPath']?>">&nbsp;</td>
<td width="91">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>


Or if you want the full size image us 'urlPath' instead of 'thumbUrlPath'.

Basically we're just assigning the list of uploads to "$uploads", then the [0] says get the first one (in PHP they start counting at zero instead of one sometimes), and then the fieldname on the end is what you want to display.

Hope that helps! Let me know if it works for you!
Dave Edis - Senior Developer

interactivetools.com