5 posts by 3 authors in: Forums > CMS Builder
Last Post: February 18   (RSS)

Sorry for my stupid question: i would like to have a certain behaviour if "reviewRecord" exists, and another behaviour if reviewRecord doesn't exist. How can i make this?

Thank you in advance for your help

Orazio 

Hi Orazo,

If statements can offer this kind of results you're looking for.

So if you're looking for a simple "no records found" vs "records are found" indicator, you can try something like this on your page after any searching criteria results:

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

<?php elseif ($your_sectionRecords) : ?>

Record(s) were found!<br/><br/>

<?php endif ?>

There are many othre examples of using if statements both here on the forum and in my CMSB Cookbook http://www.thecmsbcookbook.com 

Hope that helps.

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!

Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Thank You Jerry! But it doesn'work for me.

I have this code 

list($reviewRecords, $reviewMetaData) = getRecords(array(
'tableName' => 'review',
'where' => 'restaurant = ' . getNumberFromEndOfUrl(),
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$reviewRecord = @$reviewRecords[0]; // get first record

So i would like to have "no records found" 'where' => 'restaurant = ' . getNumberFromEndOfUrl(), 

Any suggestions about this?

instead of using ! (not) try using the empty function since you are testing an array.

$reviewRecord = @$reviewRecords[0]; // get first record

if (empty($reviewRecord))   {
  echo "no records found";
}
------------



Jeff Shields