 | |  |
 |

sagentic
User

Jul 15, 2008, 4:26 PM
Post #1 of 3
(396 views)
Shortcut
|
|
Notice: Undefined index:
|
Can't Post
|
|
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> </td> </tr> <?php endforeach; ?> </table> My code at the top of the page is:
<?php /* STEP 1: LOAD RECORDS - Copy this PHP code block to the TOP of your page BEFORE anything else. */ 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, )); ?>
|
|
|  |
 |

Donna
Staff
/ Moderator

Jul 16, 2008, 3:54 PM
Post #2 of 3
(372 views)
Shortcut
|
|
Re: [sagentic] Notice: Undefined index:
[In reply to]
|
Can't Post
|
|
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
Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.
|
|
|  |
 |

Dave
Staff
/ Moderator

Jul 16, 2008, 11:13 PM
Post #3 of 3
(358 views)
Shortcut
|
|
Re: [sagentic] Notice: Undefined index:
[In reply to]
|
Can't Post
|
|
Hi sagentic, Any time you get 'undefined index' it means you're trying to use a field that isn't defined. A neat trick for seeing all the fields available in a variable is this little snippet of code: <xmp><?php print_r($record) ?></xmp> In this case, though, both of your viewers have 'loadUploads' turned off so they're no defining the upload fields. Try removing this line from both: 'loadUploads' => '0', Hope that helps! Dave Edis - Senior Developer interactivetools.com
|
|
|  |
|