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

HI Chris, 

I added <?php $count = 0; ?> right before every foreach. It's still coming up the same way. 

Any thoughts?  Thanks! Tina
http://www.superiorequinesires.com/stallion-list7status.php

<?php $count = 0; ?>
<?php foreach ($stallion_listRecords as $record): ?>

Thanks Greg!!!!!!

I added the line at the beginning of each status listing in place of *breed = breed name* and it worked perfect!! Thanks again. Tina

http://www.superiorequinesires.com/stallion-list7status.php

<?php foreach ($stallion_listRecords as $record): ?>
<?php if (strpos($record['status'],"\tIn-Stock\t") !== false) : ?>

Hi Tina,

Glad I could help! Are you still having issues with the counter? Or has my previous post helped you resolve that issue?

Thanks!

Greg

Greg Thomas

PHP Programmer - interactivetools.com

Hi Greg!

No, I'm still having issues with the row/column displays.  I've tried two ways - one with the <?php $count = 0; ?> and the other with div tags.  Ideally, I would be okay with getting these current lists to work with the <?php $count = 0; ?> but then also determining what's wrong with my nested div tags so I can use that method in the future.  I'm sure it's something obvious... I'm just not seeing it.  Thanks a ton for your help!!! 

HTML TABLE WITH 0 COUNT: 

<table width="175" border="1" cellpadding="3" cellspacing="0" bordercolor="#D7C59C" >                       <tr>                       <?php $count = 0; ?>                         <?php foreach ($stallion_listRecords as $record): ?>                         <?php if (strpos($record['status'],"\tIn-Stock\t") !== false) : ?>                         <td align="left" valign="top"><table width="170" cellpadding="0" cellspacing="2">                             <tr>                               <td height="20" valign="bottom"><h3><a href="<?php echo $record['_link'] ?>"><?php echo htmlencode($record['title']) ?></a></h3></td>                             </tr>                             <tr>                               <td class="content"><?php echo htmlencode($record['price']) ?> </td>                             </tr>                             <tr>                               <td><?php if (!$stallion_listRecords): ?>                                 No records were found!                                 <?php endif ?>                         <!-- /STEP2: Display Records -->                              </td>                             </tr>                         </table></td>                         <?php $maxCols=3; if (@++$count % $maxCols == 1): ?>                       </tr>                       <tr>                         <?php endif; ?>                         <?php endif; ?>                         <?php endforeach ?>                       </tr>                   </table>

Example: http://www.superiorequinesires.com/stallion-list8status.php
(skipped table cells at top of most headings)

DIV TAGS:

<?php foreach ($stallion_listRecords as $record): ?> <?PHP if ($record['breed'] == "Anglo-Arabian"): ?> <div class="container"> <div class="cell">    <div><h3>    <?php if($record['stallion_url']) : ?> <a href="<?php echo $record['stallion_url']; ?>"><?php echo htmlencode($record['title']); ?></a> <?php else : ?> <a href="<?php echo $record['_link']; ?>"><?php echo htmlencode($record['title']); ?></a> <?php endif; ?> </h3></div> <div>    <?php echo htmlencode($record['price']) ?>             <?php if ($record['status'] == 'New') : ?>              <img src="http://www.superiorequinesires.com/images/icon-star-new-stallions.png" width="26" height="26" />             <?PHP endif ?>             <?php if ($record['status'] == 'Special') : ?>              <img src="http://www.superiorequinesires.com/images/icon-star-new-stallions.png" width="26" height="26" />             <?PHP endif ?>             <?php echo join(', ', $record['status:labels']); ?> <?php if (!$stallion_listRecords): ?> No records were found!             <?php endif ?> </div> </div> </div> <div class="clear"></div> <?php endif; ?> <?php endforeach ?>

Example:  http://www.superiorequinesires.com/stallion-list7breeds.php
(no columns - just rows)

Thanks!! 

Hi csdesign,

I'm having a little trouble working out what the issue is as the all of the code you've posted is on one line. Would it be possible to format the code so that everything is on separate lines?

Thanks!

Greg

Greg Thomas

PHP Programmer - interactivetools.com

Sorry... that's just how my code pastes in. Maybe it's my browser. 

I never did get the Icons to work either (code just below) ...but that's not as important (from div tag example) but I also haven't tried the strpos on it yet to see if it applies to that instance also. 

<?php if ($record['status'] == 'Special') : ?>              
<img src="http://www.superiorequinesires.com/images/icon-star-new-stallions.png" width="26" height="26" />

HTML TABLE WITH 0 COUNT: 

<table width="175" border="1" cellpadding="3" cellspacing="0" bordercolor="#D7C59C" >                       
<tr>                       
<?php $count = 0; ?>                         
<?php foreach ($stallion_listRecords as $record): ?>                         
<?php if (strpos($record['status'],"\tIn-Stock\t") !== false) : ?>                         
<td align="left" valign="top"><table width="170" cellpadding="0" cellspacing="2">                             
<tr>                               
<td height="20" valign="bottom">
<h3><a href="<?php echo $record['_link'] ?>"><?php echo htmlencode($record['title']) ?></a></h3>
</td>                             
</tr>                             
<tr>                               
<td class="content"><?php echo htmlencode($record['price']) ?> </td>                             
</tr>                             
<tr>                               
<td><?php if (!$stallion_listRecords): ?>                                 
No records were found!                                 
<?php endif ?>                         
<!-- /STEP2: Display Records -->                              
</td>                             
</tr>                         
</table></td>                         
<?php $maxCols=3; if (@++$count % $maxCols == 1): ?>                       
</tr>                       
<tr>                         
<?php endif; ?>                         
<?php endif; ?>                         
<?php endforeach ?>                       
</tr>                   
</table>

Example: http://www.superiorequinesires.com/stallion-list8status.php
(skipped table cells at top of most headings)

DIV TAGS:

<?php foreach ($stallion_listRecords as $record): ?>
<?PHP if ($record['breed'] == "Anglo-Arabian"): ?>
<div class="container">
<div class="cell">   
<div>
<h3>   
<?php if($record['stallion_url']) : ?> <a href="<?php echo $record['stallion_url']; ?>">
<?php echo htmlencode($record['title']); ?></a>
<?php else : ?> <a href="<?php echo $record['_link']; ?>"><?php echo htmlencode($record['title']); ?></a>
<?php endif; ?>
</h3>
</div>
<div>   
<?php echo htmlencode($record['price']) ?>             
<?php if ($record['status'] == 'New') : ?>             
<img src="http://www.superiorequinesires.com/images/icon-star-new-stallions.png" width="26" height="26" />             
<?PHP endif ?>             
<?php if ($record['status'] == 'Special') : ?>             
<img src="http://www.superiorequinesires.com/images/icon-star-new-stallions.png" width="26" height="26" />             
<?PHP endif ?>             
<?php echo join(', ', $record['status:labels']); ?>
<?php if (!$stallion_listRecords): ?> No records were found!             
<?php endif ?>
</div>
</div>
</div>
<div class="clear"></div>
<?php endif; ?> <?php endforeach ?>

Example:  http://www.superiorequinesires.com/stallion-list7breeds.php
(no columns - just rows)

Thanks!! 

Hi csdesign,

Not a problem! The WYSIWYG can be a little temperamental when it comes to pasting text. First off the fix the the Special icon:

<?php if (strpos($record['status'],"\tSpecial\t") !== false) : ?> 
<img src="http://www.superiorequinesires.com/images/icon-star-new-stallions.png" width="26" height="26" />

So this uses the same method used in a previous post to check if the status is special, and display the icon if it is.

I organised the code that's displaying the table so that it's tab separated, which makes it easier to spot the issues:

<table width="175" border="1" cellpadding="3" cellspacing="0" bordercolor="#D7C59C" >                       
  <tr>                       
    <?php $count = 0; ?>                         
    <?php foreach ($stallion_listRecords as $record): ?>                         
      <?php if (strpos($record['status'],"\tIn-Stock\t") !== false) : ?>                         
        <td align="left" valign="top"><table width="170" cellpadding="0" cellspacing="2">                             
          <tr>                               
            <td height="20" valign="bottom">
            <h3>
              <a href="<?php echo $record['_link'] ?>"><?php echo htmlencode($record['title']) ?></a>
            </h3>
            </td>                             
            </tr>                             
            <tr>                               
            <td class="content"><?php echo htmlencode($record['price']) ?> </td>                             
            </tr>                             
          <tr>                               
        <td>
        <?php if (!$stallion_listRecords): ?>                                 
            No records were found!                                 
          <?php endif ?>                         
          <!-- /STEP2: Display Records -->                              
          </td>                             
          </tr>                         
          </table></td>                         
          <?php $maxCols=3; if (@++$count % $maxCols == 1): ?>                       
          </tr>                       
          <tr>                         
        <?php endif; ?>                         
      <?php endif; ?>                         
    <?php endforeach ?>                       
  </tr>                   
</table>

I've rearranged the code, and this should work:

<?php if ($stallion_listRecords): ?>                                 
<table width="175" border="1" cellpadding="3" cellspacing="0" bordercolor="#D7C59C" >                       
  <tr>                       
    <?php $count = 0; ?>                         
    <?php foreach ($stallion_listRecords as $record): ?>                         
      <?php if (strpos($record['status'],"\tIn-Stock\t") !== false) : ?>                         
        <td align="left" valign="top"><table width="170" cellpadding="0" cellspacing="2">                             
          <tr>                               
            <td height="20" valign="bottom">
            <h3>
              <a href="<?php echo $record['_link'] ?>"><?php echo htmlencode($record['title']) ?></a>
            </h3>
            </td>                             
            </tr>                             
            <tr>                               
            <td class="content"><?php echo htmlencode($record['price']) ?> </td>                             
          </tr>                             
        <td>
        <?php $maxCols=3; if (@++$count % $maxCols == 1): ?>                       
        </tr>                       
        <tr>                         
        <?php endif; ?>              
      <?php endif; ?>                         
    <?php endforeach ?>                       
  </tr>  
</table>
<?php else: ?>
  No Records found!
<?php endif; ?>

  • I've moved the code that checks if the stallion records exsist outside of the foreach loop.
  • I've moved the system that adds a digit to the counter outside of the code that checks if a stallion records existed. 

Let me know if this doesn't fix the issue!

Thanks!

Greg

Greg Thomas

PHP Programmer - interactivetools.com

Greg, thanks for your help! The special icon works perfectly now. :) 

On the 3 column display... it's giving me all kinds of fits. I've tried many many variations but can't get it. I've just put the original code you sent back in so you can see the page.
http://www.superiorequinesires.com/stallion-list8status.php

Maybe I should just go with the div sample for text displays instead?  Maybe that one would cooperate better. (listed in previous post)

Thanks!! Tina

Hi Tina,

I've had a quick look a the code, and I think this is the issue:

<?php if ($stallion_listRecords): ?>                                 
<table width="175" border="1" cellpadding="3" cellspacing="0" bordercolor="#D7C59C" >                       
  <tr>                       
    <?php $count = 0; ?>                         
    <?php foreach ($stallion_listRecords as $record): ?>                         
      <?php if (strpos($record['status'],"\tIn-Stock\t") !== false) : ?>                         
        <td align="left" valign="top"><table width="170" cellpadding="0" cellspacing="2">                             
          <tr>                               
            <td height="20" valign="bottom">
            <h3>
              <a href="<?php echo $record['_link'] ?>"><?php echo htmlencode($record['title']) ?></a>
            </h3>
            </td>                             
            </tr>                             
            <tr>                               
            <td class="content"><?php echo htmlencode($record['price']) ?> </td>                             
          </tr>                             
        </td>
        <?php $maxCols=3; if (@++$count % $maxCols == 0): ?>                       
        </tr>                       
        <tr>                         
        <?php endif; ?>              
      <?php endif; ?>                         
    <?php endforeach ?>                       
  </tr>  
</table>
<?php else: ?>
  No Records found!
<?php endif; ?>

The problem is that the code is missing a closing tag somewhere. I've highlighted the tag I suspect is causing the problem in green. I think the issue might also be that the system that checks if a new row needs adding should be checking to see if the left over value is zero, and not one.

If this doesn't work, would it be possible to fill out a second level support request for me? You can find the form here:

https://www.interactivetools.com/support/email_support_form.php

I think it will be easier for me to work out where what the missing closing tag is if I can work directly on the page.

Thanks!

Greg

Greg Thomas

PHP Programmer - interactivetools.com

geez.. UNBELIEVABLE how something so simple can be such a pain.  Finally got it!  (my code does not keep it's format when I paste it in so I just took a screenshot  - attached)

Thanks!! 

Attachments:

picture-12.png 28K