Display data in a DIV

9 posts by 3 authors in: Forums > CMS Builder
Last Post: May 23, 2012   (RSS)

By Rewmer - May 23, 2012

I am trying to get my data for my list page and detail pages to display in seperate DIVs rather than tables. I want the DIV to be created for each record loaded rather than have a set number of DIVS on the page which I have done here - http://www.genetic-gems.com/pages/royalavailabledetail.php?2 - as you can see as I only have two images I am still getting the bottom borders of the empty DIVS showing... I wish I knew more PHP [mad]

Can anyone give me a quick heads up on how to acheive this ?

Re: [Rewmer] Display data in a DIV

By zip222 - May 23, 2012

Can you post the code you are currently using for that section of the page?

Re: [Rewmer] Display data in a DIV

By zip222 - May 23, 2012

What you need to do is add an if statement to each one of these. Below is an example for the first image upload. The only things that have been added are the very first and very last lines.

<?php if($avaliable_royal_pythonsRecord['picture_1']): ?>

<div class="innercontent">
<blockquote>
<?php foreach ($avaliable_royal_pythonsRecord['picture_1'] as $index => $upload): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>
info1 (Gems Code) : <?php echo htmlencode($upload['info1']) ?><br/>
info2 (Animal) : <?php echo htmlencode($upload['info2']) ?><br/>
info3 (Price) : <?php echo htmlencode($upload['info3']) ?><br/>
<?php endforeach ?>
</blockquote>
</div>

<?php endif; ?>

Re: [zip222] Display data in a DIV

By Rewmer - May 23, 2012

Thanks zip, I just knew it would be simple. I will give that a go shortly and let you know how I get on.
Thanks again.

Re: [Rewmer] Display data in a DIV

By zip222 - May 23, 2012

On second view, below is better, simpler approach. The foreach statement is sort of like an if statement. If there isn't an image, it won't output any of the html inside of it.

<?php foreach ($avaliable_royal_pythonsRecord['picture_1'] as $index => $upload): ?>
<div class="innercontent">
<blockquote>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>
info1 (Gems Code) : <?php echo htmlencode($upload['info1']) ?><br/>
info2 (Animal) : <?php echo htmlencode($upload['info2']) ?><br/>
info3 (Price) : <?php echo htmlencode($upload['info3']) ?><br/>
</blockquote>
</div>
<?php endforeach ?>

Re: [zip222] Display data in a DIV

By Rewmer - May 23, 2012

Nice work Zip, Sooo simple, she is looking fine now. Thanks very much.

Re: [zip222] Display data in a DIV

By ross - May 23, 2012

Hi there

Thanks for helping out on this one! Sounds like exactly what was needed. Appreciate your effort :).
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [Rewmer] Display data in a DIV

By ross - May 23, 2012

Hi there

Thanks for the update! Glad to hear you got things going. Keep us all update with how you are making out.

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/