Sorting Results in Tables

7 posts by 2 authors in: Forums > CMS Builder
Last Post: September 11, 2008   (RSS)

By kitka - September 3, 2008

I would like to know how to split up the results into 2 tables with the text results on1 side and the photo on the other?
Here is what is display now and it outputs everything one after another...

Can anyone hep

I

<td>
<?php foreach ($malesRecords as $record): ?>
Record Number: <?php echo $record['num'] ?><br/>
Title: <?php echo $record['title'] ?><br/>
name: <?php echo $record['name'] ?><br/>
dob: <?php echo $record['dob'] ?><br/>
sire: <?php echo $record['sire'] ?><br/>
dam: <?php echo $record['dam'] ?><br/>
Content: <?php echo $record['content'] ?><br/>
claa: <?php echo $record['claa'] ?><br/>
awards: <?php echo $record['awards'] ?><br/>
colour: <?php echo $record['colour'] ?><br/>
<br/>


<!-- STEP 2a: Display Uploads for field 'mainphoto' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
<?php foreach ($record['mainphoto'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>

<?php endif ?>
<?php endforeach ?>
<!-- STEP2a: /Display Uploads -->


<br><br>
<?php endforeach; ?>

<?php if (!$malesRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->
</td>

DOES ANYONE KNOW WHAT THE CODE WOULD BE SO THAT THIS COULD BE DICVIDED UP
WITH THE TEXT CONTENT ON THE LEFT SIDE AND THE PHOTO PART sTEP 2
DIPLAY ON THE RIGHT SIDE
SO INSTEAD OF ONE COLOUR STRAIGHT DOWN HAVE TWO COLUMS OR POSSIBLE 3


also is it possible to have the thumbnails that are generated be clickable to view a larger photo?


Any help is appreciated
JIM
jim albert

Re: [kitka] Sorting Results in Tables

By Dave - September 4, 2008

Hi Jim, welcome to the CMS Builder forum! :)

You can link a thumbnail to a larger image with this code (changes in red):

<a href="<?php echo $upload['urlPath'] ?>"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" border="0" /></a><br><br>

And for splitting the images into 2 tables yes it's possible. There's a few ways to do it. One would be a large table with 2 columns. One for the content and one for the images.

The first step is to create an html mockup of what you want it to look like. Then post a link to that and we can give you some ideas on how to make it work.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Sorting Results in Tables

By kitka - September 4, 2008

ok here is what is presently ( the .php file)
http://www.rocaroalpacas.ca/males2.php

HERE IS WHAT I WANT IT TO LOOK LIKE...

http://www.rocaroalpacas.ca/males2.html

THNAKS JIM
jim albert

Re: [kitka] Sorting Results in Tables

By Dave - September 4, 2008

Try something like this:

<table>

<?php foreach ($malesRecords as $record): ?>
<tr>
<td valign="top">
Insert text fields here:

Title: <?php echo $record['title'] ?><br/>
name: <?php echo $record['name'] ?><br/>
dob: <?php echo $record['dob'] ?><br/>
etc...

</td><td>

Insert images here

<?php foreach ($record['mainphoto'] as $upload): ?>

<a href="<?php echo $upload['urlPath'] ?>"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" border="0" /></a><br><br>
<?php endforeach ?>

</td>
</tr>
<?php endforeach ?>
</table>


Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [kitka] Sorting Results in Tables

By kitka - September 11, 2008

Ok thanks...

One other question....


How can i make the images when i click on them open up in anew browser window on top of the page...
I don't want people clicking out of the site....

The present code looks like this:

Insert images here

<?php foreach ($record['mainphoto'] as $upload): ?>

<a href="<?php echo $upload['urlPath'] ?>"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" border="0" /></a><br><br>
<?php endforeach ?>

</td>

jim albert

Re: [kitka] Sorting Results in Tables

By Dave - September 11, 2008

Try adding this code (in red): target = "_blank"

<?php foreach ($record['mainphoto'] as $upload): ?>
<a href="<?php echo $upload['urlPath'] ?>" target="_blank"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" border="0" /></a><br><br>
<?php endforeach ?>


Hope that helps!
Dave Edis - Senior Developer
interactivetools.com