Details page with picture links to other in same category

13 posts by 2 authors in: Forums > CMS Builder
Last Post: September 17, 2013   (RSS)

By thenetgirl - September 16, 2013

ok Jason I have lost my mind

the bottom nav only shows the project I am working on  ...I am so lost

<?php header('Content-type: text/html; charset=utf-8'); ?>
/* 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('/home/greensul/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 record from 'projects'
  list($projectsRecords, $projectsMetaData) = getRecords(array(
    'tableName'   => 'projects',
    'where'       => whereRecordNumberInUrl(0),
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  $projectsRecord = @$projectsRecords[0]; // get first record
  if (!$projectsRecord) { dieWith404("Record not found!"); } // show error message if no record found
  list($relatedProjects, $relatedProjectsMetaData) = getRecords(array(
    'tableName'  =>  'projects',
    'allowSearch'  =>  false,
     'where'        =>  "project_type = '".mysql_escape($projectsRecord['project_type'])."' AND num != '".intval($projectsRecord['num'])."'",


      <div style="color: rgb(0, 0, 0); font-family: verdana; font-size: 12px; letter-spacing: 1px; line-spacing; line-height:120%; width:900px; height:63px">
           <hr color="#808080" size="1">
        <b><font size="2">RELATED PROJECTS - <?php echo $projectsRecord['project_type'] ?></font></b><hr color="#808080" size="1">

    <table border="0"  id="table2" cellspacing="5" cellpadding="5" width="100%">
    <?php foreach ($relatedProjects  as $record): ?>        
        <td width="25%" valign="top" bgcolor="#FFFFFF">

                  <div class="project_thumbnail">       
 <?php foreach ($projectsRecord['snapshot'] as $index => $upload): ?>
              <a href="<?php echo $projectsRecord['_link'] ?>"><img src="<?php echo $upload['thumbUrlPath2'] ?>" width="<?php echo $upload['thumbWidth2'] ?>" height="<?php echo $upload['thumbHeight2'] ?>" alt="" /></a>
                <div style="color:#333333; font:Verdana; font-size: 11px;  text-transform: uppercase"><b><?php echo htmlencode($projectsRecord['title']) ?></b></font></div>   
<?php endforeach ?>      
        <?php $maxCols=4; if (@++$count % $maxCols == 0): ?>    <tr></tr>
                                                            <?php endif; ?>
        <?php endforeach ?>



10projectsdetail.php 10K

By Jason - September 17, 2013


I took a look at your code.  What's happening is that you are using $relatedProjects for your foreach loop, which is correct, but you are outputting data from $projectsRecord inside your loop.  This is why you are getting the same record output over and over.  Try changing your foreach loop block like this:

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

  <td width="25%" valign="top" bgcolor="#FFFFFF">
    <div class="project_thumbnail">
      <?php foreach ($record['snapshot'] as $index => $upload): ?> 
  <a href="<?php echo $record['_link'] ?>"><img src="<?php echo $upload['thumbUrlPath2'] ?>" width="<?php echo $upload['thumbWidth2'] ?>" height="<?php echo $upload['thumbHeight2'] ?>" alt="" /></a>
<div style="color:#333333; font:Verdana; font-size: 11px;  text-transform: uppercase"><b><?php echo htmlencode($record['title']) ?></b></font></div>       
      <?php endforeach ?>   
      <?php $maxCols=4; if (@++$count % $maxCols == 0): ?>
<?php endif; ?>
<?php endforeach ?>

Hope this helps

Jason Sauchuk - Project Manager

Hire me! Save time by getting our experts to help with your project.

By thenetgirl - September 17, 2013

Got it thanks Jason