close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Help with repeating tables

Thread began 12/22/2015 12:06 pm by iain331081 | Last modified 12/23/2015 8:01 pm by Ray Borduin | 832 views | 8 replies |

iain331081

Help with repeating tables

A while ago I got some help to display the first record in a recordset in one part of a page, and the next x records in another part, and the next y records in a third part.

I have been looking at combining that with the repeating tables function, but not quite got it, and could do with a little help.

Details below....

Sign in to reply to this post

Ray BorduinWebAssist

You had some leftover code from the other page on this one. I removed it and updated the number of rows to get it working properly.

Sign in to reply to this post

iain331081

Thanks Ray - really sorry, but I think I overwrote it with my old version.

Could you re-upload the updated version if you still have it?

Thanks.

Sign in to reply to this post

Ray BorduinWebAssist

I just re-uploaded it

Sign in to reply to this post

iain331081

Thanks Ray - just looking at the code to try to see what's doing what.

Is that using a different method? I thought the other one used data seek to show the first record:

<?php
mysql_data_seek($rsProductUpdates, 0);
$row_rsProductUpdates = mysql_fetch_assoc($rsProductUpdates);
?>

And subsequent records (e.g. 2-10):

<?php for($i=1;$i<=10;$i++) { ?>

<?php
mysql_data_seek($rsProductUpdates, $i);
$row_rsProductUpdates = mysql_fetch_assoc($rsProductUpdates);
?>

With this page it looks like you added LIMIT 21 at the end of the SQL to control how many records appear on the page, and 20 iterations in the repeating table.

But what makes it show the first record at the top, and then records 2-21 in the repeating table?

I'm just wondering how much of a pain it might be to have more than one repeating table on the page to break it up and make it look a little less repetitive, for example:

1 story at the top showing record 1

Repeating table showing records 2 - 5 in a single row of 4

Repeating table showing records 6 - 15 in 4 rows of 2

Repeating table showing records 16 - 19 in a single row of 4

Repeating table showing records 20 - 29 in 4 rows of 2

Or something like that at least.

Would it just be a case of adding more repeating tables, with the specified number of iterations, and altering the LIMIT in the SQL?

Also, I'm using Substr(update_details, 1, 140) AS summary text to limit the text to the the first 140 characters of the news item. Do you know any little tricks to do that without truncating in the middle of a word, i.e. 140 characters + however many before the first blank space, period?

Sign in to reply to this post

Ray BorduinWebAssist

I add limit 21 to the query for efficiency. It would still only display the 21 without it, but since I know only 21 records are being shown there is no reason to retrieve more.

The first record is always first, so I don't need to do anything to show the first record.

On line 238 I add a call to mysql_fetch_assoc() to move to the next record (second) before starting the loop:

php:
<?php  

            $row_rsProductUpdates 
mysql_fetch_assoc($rsProductUpdates); 
?>



The number of rows actually displayed is controlled by line 117 in the loop settings:

$RepeatSelectionCounter_1449935665360_Iterations = "20";



To have it not break in the middle of a word, I'd return more characters than you need in the sql query, maybe change it to 160... then add a function to the php:

php:
<?php

function truncate($str$width) {
    
$str str_replace("\n"," ",$str);
    return 
strtok(wordwrap($str$width"...\n"), "\n");
}
?>



And then display the column using that function like:

php:
<?php echo(truncate($row_rsProductUpdates['summarytext'], 140)); ?>



Breaking it into multiple repeated regions shouldn't be an issue... just lower the number in the first one on line 117 and add more repeated regions for the others. You wouldn't really need to change the limit in the SQL unless you were displaying more than 21 total rows.

Sign in to reply to this post

iain331081

Thanks Ray - the truncating of words is working great at index5.php.

I have tried adding another repeated region at index6.php (lines 380-500) but must have something wrong. Its drawing a blank page due to a syntax error at line 495.

I thought maybe I needed to delete line 354:

<?php } // Show if recordset empty ?>

As that is only needed once at the end, rather than after each repeating region.

It didn't report any errors, but the page then only displays the first record.

I have attached a copy below.

Hopefully this is nearly it - once I have a couple working I can play around with others to get to a final layout for the page.

Sign in to reply to this post

Ray BorduinWebAssist

You need an end for every start... in this case you had three ends and one start and no end for the show if recordset not empty.

I've fixed it on your site, but debugging hand coding is a bit beyond what we usually do on this forum. In the future I'll have to ask you to sign up for premier support to help you debug things like this.

Sign in to reply to this post

iain331081

Thanks Ray - really appreciate that. In future do let me know if something crosses the line to a premium ticket.

I don't know if DW is messing about, but despite being careful I managed to overwrite that again - could you reupload it again?

Thank you.

Edit - think I fixed it at index201.php

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...