close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

showing content based on column

Thread began 11/15/2018 7:09 am by Jamie | Last modified 11/22/2018 10:28 am by Ray Borduin | 1507 views | 8 replies |

Jamie

showing content based on column

Hey Ray

On the attached page, I have a recordset (Downloads) repeated several times starting at line 12 to show depending on which DownloadType and just wondering if there is a better way to effect the same result?

Also, and further down the page (starting at line 99) a box which I want to display downloadable pdf's chronologically - so far have got that for 2018.

There are other downloads which have year dates (2017, 2016 etc) and if there are downloads with a year date I somehow need to get further boxes uses the same styling to then list the content in those subsequent boxes.

I hope that you're able to make sense of that?

Cheers

Jamie

Sign in to reply to this post

Ray BorduinWebAssist

You could clean it up a little by replacing lines 11-51 with:

php:
<?php

$Downloads 
= new WA_MySQLi_RS("Downloads",$DBConnection,0);
$Downloads->setQuery("SELECT * FROM download WHERE DownloadType = ? AND Live = 1 ORDER BY DownloadDate ASC");
$PageContents->bindParam("i""".($PageContents->getColumnVal("ServicesID"))  ."""-1"); //paramOffersID
$Downloads->execute();
?>



Your code that starts on line 99:

php:
<?php if ($Downloads->TotalRows 0) { // Show if mysqli recordset not empty ?>

        <div class="container downloadWrapper">
          <h3 class="heading-1">2018</h3>
          <div class="container downloadContainer">
            <?php
$wa_startindex 
0;
while(!
$Downloads->atEnd()) {
  
$wa_startindex $Downloads->Index;
?>
              <a class="link-text downloadLnk" href="downloads/<?php echo($Downloads->getColumnVal("DownloadFile")); ?>" target="_blank"><?php echo($Downloads->getColumnVal("DownloadTitle")); ?><br>
              </a>
              <?php
  $Downloads
->moveNext();
}
$Downloads->moveFirst(); //return RS to first record
unset($wa_startindex);
unset(
$wa_repeatcount);
?>
          </div>
        </div>
        <?php // Show if mysqli recordset not empty ?>



You could update to something like:

php:
<?php if ($Downloads->TotalRows 0) { // Show if mysqli recordset not empty ?>

        <div class="container downloadWrapper">
<?php
$showYear 
"";
?>
            <?php
$wa_startindex 
0;
while(!
$Downloads->atEnd()) {
  
$wa_startindex $Downloads->Index;
?>
<?php
if ($showYear != date("Y"strtotime($Downloads->getColumnVal("DownloadDate")))) {
?>
          <h3 class="heading-1"><?php echo(date("Y"strtotime($Downloads->getColumnVal("DownloadDate"))); ?></h3>
          <div class="container downloadContainer">
<?php
}
?>
              <a class="link-text downloadLnk" href="downloads/<?php echo($Downloads->getColumnVal("DownloadFile")); ?>" target="_blank"><?php echo($Downloads->getColumnVal("DownloadTitle")); ?><br>
              </a>
<?php
if ($showYear != date("Y"strtotime($Downloads->getColumnVal("DownloadDate")))) {
  
$showYear date("Y"strtotime($Downloads->getColumnVal("DownloadDate"));
?>
          </div>
<?php
}
?>
              <?php
  $Downloads
->moveNext();
}
$Downloads->moveFirst(); //return RS to first record
unset($wa_startindex);
unset(
$wa_repeatcount);
?>
        </div>
        <?php // Show if mysqli recordset not empty ?>
Sign in to reply to this post
Did this help? Tips are appreciated...

Jamie

thanks Ray - 1st answer exactly what I was looking for but completely forgot how to do

2nd on eis almost there but each month is showing in its own year container when am trying to get all the months from 2018 in same container, all the ones from 2017 in same container etc

At the moment it looks like this: http://clients.motley.site/hbpc/pc/parish-council-agendas updated page attached

Sign in to reply to this post

Ray BorduinWebAssist

You have an extra semi-colon at the end of lines 75 and 85... remove those and it should work.

Sign in to reply to this post
Did this help? Tips are appreciated...

Jamie

thanks Ray.... almost there. The containers for each available should look like this http://prntscr.com/liu8ez

It looks like the first record in each is falls within the <div> but then the others dont. http://prntscr.com/liu9x8 reed is the first record and blue are the subsequent

Also, how would you sort the year DESC and then the records by ASC?

Sign in to reply to this post

Ray BorduinWebAssist

SELECT * FROM download WHERE DownloadType = ? AND Live = 1 ORDER BY YEAR(DownloadDate) DESC, DownloadDate ASC

And I think I see the error in my logic... try this:

php:
<?php if ($Downloads->TotalRows 0) { // Show if mysqli recordset not empty ?>

        <?php
$showYear 
"";
?>
        <?php
$wa_startindex 
0;
while(!
$Downloads->atEnd()) {
  
$wa_startindex $Downloads->Index;
?>
<?php
if ($showYear != date("Y"strtotime($Downloads->getColumnVal("DownloadDate")))) {
?>
<?php
if ($showYear != "") echo("</div></div>");
      
?><div class="container downloadWrapper">
            <h3 class="heading-1"><?php echo(date("Y"strtotime($Downloads->getColumnVal("DownloadDate")))); ?></h3>
            <div class="container downloadContainer">
              <?php
}
?>
              <a class="link-text downloadLnk" href="downloads/<?php echo($Downloads->getColumnVal("DownloadFile")); ?>" target="_blank"><?php echo($Downloads->getColumnVal("DownloadTitle")); ?></a>
              <?php
if ($showYear != date("Y"strtotime($Downloads->getColumnVal("DownloadDate")))) {
  
$showYear date("Y"strtotime($Downloads->getColumnVal("DownloadDate")));
?>
            <?php
}
?>

          <?php
  $Downloads
->moveNext();
}
$Downloads->moveFirst(); //return RS to first record
unset($wa_startindex);
unset(
$wa_repeatcount);
?></div>
            </div>
        <?php // Show if mysqli recordset not empty ?>
Sign in to reply to this post
Did this help? Tips are appreciated...

Jamie

thats brilliant and almost there - thanks so much

The only issue is that the first year shows fine, then the subsequent one(s) dont have any styling nor does the container separate so that each year is in it own as per http://prntscr.com/liu8ez

http://clients.motley.site/hbpc/pc/parish-council-agendas - updated page attached

Sign in to reply to this post

Ray BorduinWebAssist

I updated the code in my last post. Give that a try.

Sign in to reply to this post
Did this help? Tips are appreciated...

Jamie

superb. many thanks

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...