No records in category

4 posts by 2 authors in: Forums > CMS Builder
Last Post: January 11, 2010   (RSS)

By MRI - January 8, 2010

Ok.. I have a listing for hotels.. in the CMS when you add a hotel, you select from a pre determined list for that hotels location.

So on the website I have all the hotels listed and categorized by location using:
<?php if (strpos($record['location'], 'Ham Lake')): ?>

Now i need a solution to display the "No Records Found" if there are no records for that current location.
This doesnt work because its looking at ALL records not just ones labeled with the category location:
<?php if (!$hotel_listingsRecords): ?>
No records were found!<br/><br/>
<?php endif ?>

So im assuming its just tweaking this line... but I cant figure it out:
<?php if (!$hotel_listingsRecords): ?>

Re: [MRI] No records in category

By Chris - January 8, 2010

Hi MRI,

Can you please attach the complete PHP source code for your page?
All the best,
Chris

Re: [chris] No records in category

By MRI - January 11, 2010

SEE BELOW: After each section "location" If there are no records with the corresponding location, then I would like it to display the "No Records Available"


<?php $count = 0; ?>
<?php foreach ($hotel_listingsRecords as $record): ?>
<?php if (strpos($record['location'], 'Arden Hills')): ?>

<td align="left" valign="top" class="hotel_othercol">

<?php foreach ($record['logo'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<?php endforeach ?>

<h5><?php echo $record['hotel_name'] ?></h5>
<?php echo $record['details'] ?></td>

<?php $maxCols=2; if (@++$count % $maxCols == 0): ?>
</tr>
<tr>
<?php endif; ?>

<?php endif ?>
<?php endforeach; ?>

</tr>
<tr>
<td colspan="2" align="left" valign="top" class="hotel_linecell"><ul>
<li><a href="#HotelMenu">Return to menu</a></li>
</ul></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" class="hotel_locationcell"><strong><a name="Blaine" id="Blaine"></a>Blaine</strong></td>
</tr>
<tr>

<?php $count = 0; ?>
<?php foreach ($hotel_listingsRecords as $record): ?>
<?php if (strpos($record['location'], 'Blaine')): ?>

<td align="left" valign="top" class="hotel_othercol">

<?php foreach ($record['logo'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<?php endforeach ?>

<h5><?php echo $record['hotel_name'] ?></h5>
<?php echo $record['details'] ?></td>

<?php $maxCols=2; if (@++$count % $maxCols == 0): ?>
</tr>
<tr>
<?php endif; ?>

<?php endif ?>
<?php endforeach; ?>

</tr>
<tr>
<td colspan="2" align="left" valign="top" class="hotel_linecell"><ul>
<li><a href="#HotelMenu">Return to menu</a></li>
</ul></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" class="hotel_locationcell"><strong><a name="CoonRapids" id="CoonRapids"></a>Coon Rapids</strong></td>
</tr>
<tr>

<?php $count = 0; ?>
<?php foreach ($hotel_listingsRecords as $record): ?>
<?php if (strpos($record['location'], 'Coon Rapids')): ?>

<td align="left" valign="top" class="hotel_othercol">

<?php foreach ($record['logo'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<?php endforeach ?>

<h5><?php echo $record['hotel_name'] ?></h5>
<?php echo $record['details'] ?></td>

<?php $maxCols=2; if (@++$count % $maxCols == 0): ?>
</tr>
<tr>
<?php endif; ?>

<?php endif ?>
<?php endforeach; ?>

</tr>
<tr>
<td colspan="2" align="left" valign="top" class="hotel_linecell"><ul>
<li><a href="#HotelMenu">Return to menu</a></li>
</ul></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" class="hotel_locationcell"><strong><a name="ForestLake" id="ForestLake"></a>Forest Lake</strong></td>
</tr>
<tr>

<?php $count = 0; ?>
<?php foreach ($hotel_listingsRecords as $record): ?>
<?php if (strpos($record['location'], 'Forest Lake')): ?>

<td align="left" valign="top" class="hotel_othercol">

<?php foreach ($record['logo'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<?php endforeach ?>

<h5><?php echo $record['hotel_name'] ?></h5>
<?php echo $record['details'] ?></td>

<?php $maxCols=2; if (@++$count % $maxCols == 0): ?>
</tr>
<tr>
<?php endif; ?>


<?php endif ?>
<?php endforeach; ?>

</tr>
<tr>
<td colspan="2" align="left" valign="top" class="hotel_linecell"><ul>
<li><a href="#HotelMenu">Return to menu</a></li>
</ul></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" class="hotel_locationcell"><strong><a name="HamLake" id="HamLake"></a>Ham Lake</strong></td>
</tr>
<tr>

<?php $count = 0; ?>
<?php foreach ($hotel_listingsRecords as $record): ?>
<?php if (strpos($record['location'], 'Ham Lake')): ?>

<td align="left" valign="top" class="hotel_othercol">

<?php foreach ($record['logo'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<?php endforeach ?>

<h5><?php echo $record['hotel_name'] ?></h5>
<?php echo $record['details'] ?></td>

<?php $maxCols=2; if (@++$count % $maxCols == 0): ?>
</tr>
<tr>
<?php endif; ?>


<?php endif ?>
<?php endforeach; ?>

<?php if (!$hotel_listingsRecords): ?>
No records were found!<br/><br/>
<?php endif ?>

</tr>
<tr>
<td colspan="2" align="left" valign="top" class="hotel_linecell"><ul>
<li><a href="#HotelMenu">Return to menu</a></li>
</ul></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" class="hotel_locationcell"><strong><a name="LinoLakes" id="LinoLakes"></a>Lino Lake</strong>s</td>
</tr>
<tr>

<?php $count = 0; ?>
<?php foreach ($hotel_listingsRecords as $record): ?>
<?php if (strpos($record['location'], 'Lino Lake')): ?>

<td align="left" valign="top" class="hotel_othercol">

<?php foreach ($record['logo'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<?php endforeach ?>

<h5><?php echo $record['hotel_name'] ?></h5>
<?php echo $record['details'] ?></td>

<?php $maxCols=2; if (@++$count % $maxCols == 0): ?>
</tr>
<tr>
<?php endif; ?>


<?php endif ?>
<?php endforeach; ?>

</tr>
<tr>
<td colspan="2" align="left" valign="top" class="hotel_linecell"><ul>
<li><a href="#HotelMenu">Return to menu</a></li>
</ul></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" class="hotel_locationcell"><strong><a name="NorthBranch" id="NorthBranch"></a>North Branch</strong></td>
</tr>
<tr>

<?php $count = 0; ?>
<?php foreach ($hotel_listingsRecords as $record): ?>
<?php if (strpos($record['location'], 'North Branch')): ?>

<td align="left" valign="top" class="hotel_othercol">

<?php foreach ($record['logo'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<?php endforeach ?>

<h5><?php echo $record['hotel_name'] ?></h5>
<?php echo $record['details'] ?></td>

<?php $maxCols=2; if (@++$count % $maxCols == 0): ?>
</tr>
<tr>
<?php endif; ?>

<?php endif ?>
<?php endforeach; ?>


</tr>
<tr>
<td colspan="2" align="left" valign="top" class="hotel_linecell"><ul>
<li><a href="#HotelMenu">Return to menu</a></li>
</ul></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" class="hotel_locationcell"><strong><a name="VadnaisHeights" id="VadnaisHeights"></a>Vadnais Heights</strong></td>
</tr>
<tr>

<?php $count = 0; ?>
<?php foreach ($hotel_listingsRecords as $record): ?>
<?php if (strpos($record['location'], 'Vadnais Heights')): ?>

<td align="left" valign="top" class="hotel_othercol">

<?php foreach ($record['logo'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<?php endforeach ?>

<h5><?php echo $record['hotel_name'] ?></h5>
<?php echo $record['details'] ?></td>

<?php $maxCols=2; if (@++$count % $maxCols == 0): ?>
</tr>
<tr>
<?php endif; ?>

<?php endif ?>
<?php endforeach; ?>

</tr>
<tr>
<td colspan="2" align="left" valign="top" class="hotel_linecell"><ul>
<li><a href="#HotelMenu">Return to menu</a></li>
</ul></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" class="hotel_locationcell"><a name="WhiteBearLake" id="WhiteBearLake"></a>White Bear Lake</td>
</tr>

<?php $count = 0; ?>
<?php foreach ($hotel_listingsRecords as $record): ?>
<?php if (strpos($record['location'], 'White Bear Lake')): ?>

<td align="left" valign="top" class="hotel_othercol">

<?php foreach ($record['logo'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<?php endforeach ?>

<h5><?php echo $record['hotel_name'] ?></h5>
<?php echo $record['details'] ?></td>

<?php $maxCols=2; if (@++$count % $maxCols == 0): ?>
</tr>
<tr>
<?php endif; ?>

<?php endif ?>
<?php endforeach; ?>

<tr>
<td colspan="2" align="left" valign="top" class="hotel_linecell"><ul>
<li><a href="#HotelMenu">Return to menu</a></li>
</ul>