Notice: Undefined index:

3 posts by 3 authors in: Forums > CMS Builder
Last Post: July 17, 2008   (RSS)

By Kenny - July 15, 2008

Cannot figure this one out. I get an error for uploads when I try to to pull from two different tables.

Notice: Undefined index: preview_photo in /home/remaxc/public_html/index.php on line 159 Warning: Invalid argument supplied for foreach() in /home/remaxc/public_html/index.php on line 159

Notice: Undefined index: preview_photo in /home/remaxc/public_html/index.php on line 159 Warning: Invalid argument supplied for foreach() in /home/remaxc/public_html/index.php on line 159

Notice: Undefined index: preview in /home/remaxc/public_html/index.php on line 180 Warning: Invalid argument supplied for foreach() in /home/remaxc/public_html/index.php on line 180


My code is like this:
<table border="0" cellpadding="3" cellspacing="3" width="100%" id="table3">
<tr>
<td bgcolor="#CC0000">
<font color="#FFFFFF" face="Arial">Featured
Residential Properties</font></td>
</tr>
<?php foreach ($residentialRecords as $record): ?>
<tr>
<td> <?php foreach ($record['preview_photo'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" />
<?php elseif ($upload['isImage']): ?>
<?php else: ?>
<?php endif ?>
<?php endforeach ?></td>
</tr>
<tr>
<td><?php echo $record['address'] ?></td>
</tr>
<?php endforeach; ?>
<tr>
<td bgcolor="#CC0000">
<font color="#FFFFFF" face="Arial">Featured
Commercial Properties</font></td>
</tr>
<?php foreach ($commercialRecords as $record): ?>
<tr>
<td> <!-- STEP 2a: Display Uploads for field 'preview_photo' (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['preview'] 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 ?>
<!-- STEP2a: /Display Uploads --></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<?php endforeach; ?>
</table>


My code at the top of the page is:
<?php

require_once "/home/remaxc/public_html/webadmin/lib/viewer_functions.php";

list($residentialRecords, $residentialMetaData) = getRecords(array(
'tableName' => 'residential',
'limit' => '2',
'orderBy' => 'RAND()',
'loadUploads' => '0',
'allowSearch' => '0',
'useSeoUrls' => true,
));

list($commercialRecords, $commercialMetaData) = getRecords(array(
'tableName' => 'commercial',
'limit' => '2',
'orderBy' => 'RAND()',
'loadUploads' => '0',
'allowSearch' => '0',
'useSeoUrls' => true,
));

?>

Re: [sagentic] Notice: Undefined index:

By Donna - July 16, 2008

Hi there!

When you're pulling in information from two different tables, you need to have the "top of the page" code just above each "section" of code. So, instead of having both bits of code at the top, you'll need it to be ...

[top code for residential]

[residential display code]

[top code for commercial]

[commercial display code]

Basically, any time you're referring to a different table, you need to stick that "top code" in right before it, or the page doesn't know which table to pull the details from. :)

Give that a try and let me know how it works for you. :)
Donna

--
support@interactivetools.com