Code works on Details page but not on List page

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

By fleff - August 2, 2010

Why does this code work on the properties_details.php page but not on the properties.php page? It's near the top of the page above the foreach section.

<table align="center" bgcolor="#E8DEA4" width="900" border="0" cellspacing="0" cellpadding="10">
<tr>
<td align="center" valign="top">
<div class="page_title"><?php echo $propertiesRecord['listing_heading'] ?> in <?php echo $propertiesRecord['property_town'] ?>, <?php echo $propertiesRecord['state'] ?></div>
<span class="new_info"><?php echo $propertiesRecord['new_info'] ?></span>
</td>
</tr>
</table>

I get this message:

Notice: Undefined variable: propertiesRecord in /usr/home/klemmr/www/htdocs/properties.php on line 138 in Notice: Undefined variable: propertiesRecord in /usr/home/klemmr/www/htdocs/properties.php on line 138 , Notice: Undefined variable: propertiesRecord in /usr/home/klemmr/www/htdocs/properties.php on line 138

The viewer library on the properties.php page is:

// load records
list($propertiesRecords, $propertiesMetaData) = getRecords(array(
'tableName' => 'properties',
'orderBy' => 'price+0 DESC',
'perPage' => '48',
));

The rest of the page works fine in producing the list of properties. What do I need to do to make this work? I didn't find anything in the forum to help me.

Thanks,

Farnham

Re: [fleff] Code works on Details page but not on List page

By Ryan - August 3, 2010

Your code should be inserted inbetween your foreach statements on the list page. The detail page deals with a specific record were as the list page displays multiple records and therefore needs the foreach statement.

<?php foreach ($propertiesRecords as $record): ?>

<table align="center" bgcolor="#E8DEA4" width="900" border="0" cellspacing="0" cellpadding="10"> <tr> <td align="center" valign="top"> <div class="page_title"><?php echo $propertiesRecord['listing_heading'] ?> in <?php echo $propertiesRecord['property_town'] ?>, <?php echo $propertiesRecord['state'] ?></div> <span class="new_info"><?php echo $propertiesRecord['new_info'] ?></span> </td> </tr> </table>

<?php endforeach ?>



Ryan

Re: [ryan_dot] Code works on Details page but not on List page

By fleff - August 3, 2010

Thanks, Ryan, for your response. I had tried that and I get the same error message repeated on the page by the number of times that I have records for that table.

I think I see where this problem lies. I'm asking it to read the fields of all the records and there are different values in each of them, where I only want one. Actually, I'm working with a field called "status" as a header on the page that says whether the property is For Sale or For Rent. I used the sample above as an example that worked on the details page but now I see why it won't work on the list page. I'll have to approach this from another perspective. Let's see where it goes.

Farnham