close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Two recordsets on one page - how to restrict one of those to not display the results shown in the other?

Thread began 6/25/2015 9:16 am by Nathon Jones Web Design | Last modified 6/29/2015 11:08 am by Ray Borduin | 1920 views | 6 replies |

Nathon Jones Web Design

Two recordsets on one page - how to restrict one of those to not display the results shown in the other?

I have two news article recordsets on one page. The first I have set to display the latest 5 headline news articles.
I would like the another recordset to display the remaining news articles.

How do I prevent it from showing the initial 5? Articles are displayed in order of date posted.

Thank you.
NJ

Sign in to reply to this post

iain331081

I had a similar requirement ages ago, which I assume is the same sort of thing - the homepage on the site had news articles on it, but with the most recent ones given more prominence, like this:

http://www.mphrp.org

The trick turned out to be to use one recordset, and then use some PHP to control which records you show in each section. So that example has this to show the main story at the top:

<?php
mysql_data_seek($WADAtbnews, 0);
$row_WADAtbnews = mysql_fetch_assoc($WADAtbnews);
?>
CONTENT HERE

This to show the next three:

<?php for($i=1;$i<=3;$i++) { ?>
<?php
mysql_data_seek($WADAtbnews, $i);
$row_WADAtbnews = mysql_fetch_assoc($WADAtbnews);
?>
CONTENT HERE
<?php } ?>

And these to show the two columns of the oldest news further down:

<?php for($i=4;$i<=6;$i++) { ?>
<?php
mysql_data_seek($WADAtbnews, $i);
$row_WADAtbnews = mysql_fetch_assoc($WADAtbnews);
?>
CONTENT HERE
<?php } ?>

and

<?php for($i=7;$i<=9;$i++) { ?>
<?php
mysql_data_seek($WADAtbnews, $i);
$row_WADAtbnews = mysql_fetch_assoc($WADAtbnews);
?>
CONTENT HERE
<?php } ?>

Hope that makes sense and helps.

Sign in to reply to this post

Ray BorduinWebAssist

You could also use a NOT IN clause to show results in one query and limit it to results that aren't shown in another.

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

Nathon Jones Web Design

Here's my first MySQLi recordset:

<?php
$rsTOP5NEWS = new WA_MySQLi_RS("rsTOP5NEWS",$csdbmysqli,5);
$rsTOP5NEWS->setQuery("SELECT newsID, newsdate, newstitle, newssummary, newsdelete FROM news WHERE newsdelete = 2 ORDER BY newsdate DESC");
$rsTOP5NEWS->execute();?>

This returns the top 5 news items (by date).

So how should my second MySQLi recordset look?
Not being familiar with PHP I tried this without success...

<?php
$rsRESTOFNEWS = new WA_MySQLi_RS("rsRESTOFNEWS",$csdbmysqli,10);
$rsRESTOFNEWS->setQuery("SELECT newsID, newsdate, newstitle, newssummary, newsdelete FROM news WHERE newsdelete = 2 AND newsID NOT IN $rsTOP5NEWS ORDER BY newsdate DESC");
$rsRESTOFNEWS->execute();?>

Hope you can help. Thank you.
NJ

Sign in to reply to this post

Nathon Jones Web Design

Hi Iain,

It's not really prominence I'm looking for I just want to display the top 5 results in one recordset and the remaining results in another.
Not being familiar with PHP I'm lost with the example you've given there although I don't doubt that it works I'm just not sure how to convert it to my scenario where I'm using WebAssist generated MySQLi recordsets. See my other reply for details.

Thanks for any help offered.
NJ

Sign in to reply to this post

Ray BorduinWebAssist

You could just update the StartLimit for that recordset.

php:
<?php

$rsRESTOFNEWS 
= new WA_MySQLi_RS("rsRESTOFNEWS",$csdbmysqli,10);
$rsRESTOFNEWS->setQuery("SELECT newsID, newsdate, newstitle, newssummary, newsdelete FROM news WHERE newsdelete = 2 ORDER BY newsdate DESC");
$rsRESTOFNEWS->StartLimit=5;
$rsRESTOFNEWS->execute();
?>
Sign in to reply to this post
Did this help? Tips are appreciated...

iain331081

Hi Nathon - I am certainly no PHP expert, and would have found this solution on a forum, if not from Ray or Jason here.

Ray's solution is probably more elegant, and you might have got that working now.

But I think this is still what you are trying to do - maybe 'prominence' was a bad choice of word, but the idea seems the same, i.e. you are splitting the records into more than one group, based on a date.

So in my example, the most recent record appears on one place, the next few by date in another section etc.

I have attached a stripped down version of the page below, which has the code in the header with the SQL query, and the HTML / PHP in the body showing the sections.

Hopefully from that, or from Ray's solution you get it working as you would like.

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