Do not show first record

5 posts by 2 authors in: Forums > CMS Builder
Last Post: October 1, 2012   (RSS)

By Toledoh - September 29, 2012

Hi Guys,

There's probably a very simple way to action this...

I've got a combo page, with a side navigation (list) of stores, and a main div of the store details. The file is stores.php.

If I load this page, because there is no ?title-31 , it shows the first record.

Is it possible to say "if no record selected, show ..."

Thanks!
Cheers,

Tim (toledoh.com.au)

Re: [greg] Do not show first record

By Toledoh - October 1, 2012

Thanks Greg!

Rather than showing one of the items from that table, could you show something else... such as "Welcome to the directory, please make a selection from the left"... ?
Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] Do not show first record

By gregThomas - October 1, 2012

This is fairly straight forward as well. I'd just add a second variable that is true or false if $number equals zero then you can use it for displaying custom code on the page.

//This function gets the last number from the URL. If there is no number it will return 0;
$number = getLastNumberInUrl();
//This if statement will set the $number variable to the number 3 if it is currently less than 1. Change the number 3 to whatever record you want to load.
$nothingSelected = ($number < 1)? true : false;
$number = ($number < 1)? '3' : $number;


//This getRecords function uses a where statement to pull correct record from a table. Make sure allowSearch is set to false or you could run into problems.
list($mainContents, $test_1MetaData) = getRecords(array(
'tableName' => 'test_1',
'where' => "`num` = '$number'",
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$mainContent = @$mainContents[0]; // get first record


?>

<?php if($nothingSelected): ?>
<p>I'm sorry, you need to select something from the left. <p>
<?php else: ?>
<!-- Main Content goes in here -->
<?php endif ?>

Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Do not show first record

By Toledoh - October 1, 2012

Brilliant!
Cheers,

Tim (toledoh.com.au)