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  http://greens.exedor.us/10projectsdetail.php?CASTRO-STREET-7

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

<?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('/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'])."'",
  ));
 
 

?>
----------------------------------------------------------------------------------BOTTOM-----------

      <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">
       </div>

    <table border="0"  id="table2" cellspacing="5" cellpadding="5" width="100%">
        <tr>
    <?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 ?>
              </div>  
   </td>
        
    </table>



     </div>

Patricia

www.thenetgirl.com
Attachments:

10projectsdetail.php 10K

By Jason - September 17, 2013

Hi,

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): ?>
          <tr></tr>
<?php endif; ?>
        
<?php endforeach ?>

Hope this helps

---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By thenetgirl - September 17, 2013

Got it thanks Jason

PG

Patricia

www.thenetgirl.com