DISPLAYING LISTS based on fields

22 posts by 3 authors in: Forums > CMS Builder
Last Post: February 19, 2014   (RSS)

Hi csdesign,

I've had a look at your code in stallion-list8breeds.php, and I think you need to change lines 1 to 28 to the following:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
  
  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/var/www/hosted/superiorequinesires.com/public_html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  // load records from 'stallion_list'
  list($stallion_listRecords, $stallion_listMetaData) = getRecords(array(
    'tableName'   => 'stallion_list',
    "where"       => "`status` != 'Archived'",
    'loadUploads' => true,
    'allowSearch' => false,
  ));
  // load record from 'stallion_roster_text'
  list($stallion_roster_textRecords, $stallion_roster_textMetaData) = getRecords(array(
    'tableName'   => 'stallion_roster_text',
    'where'       => '', // load first record
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $stallion_roster_textRecord = @$stallion_roster_textRecords[0]; // get first record
  if (!$stallion_roster_textRecord) { dieWith404("Record not found!"); } // show error message if no record found

?>

The line highlighted in green is the new code. It inserts a where statement into the MySQL call to the database that will only return records that do have a status of Archived.

Let me know if you have any questions, or if the code doesn't work. 

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com