Jump to content

Show link if....


Recommended Posts

I have a page which shows up to 5 news links from a regularly updated database, using a repeat region. When there are more than 5, the oldest link drops into an archive page which is specific to the current month. At the bottom of the 5 items, I have an html link to the archive page, which works fine as is. However, now I want to make this link's visibility conditional on the number of links on the main page - as in show if there are more than 5 items, and hide if there are 5 or less.

Hopefully this makes sense, if not, please ask!

 

Currently the db query for the items to display is this:

SELECT *
FROM tblNews
ORDER BY tblNews.newsID DESC

with a repeat region of only 5 items.

 

This is the part I want to tie to the recordset:

 <p><a href="newslinkpage.php" title="link to news articles pages">More articles</a></p>

 

I've tried LIMIT, which doesn't seem to like the idea, and I'm a bit stumped as to where to look next. Anyone able to point me in the right direction for wording the queryset?

 

Many thanks.

 

J

Link to comment
Share on other sites

  • 4 weeks later...

[!--quoteo(post=333515:date=Jan 5 2006, 06:25 AM:name=degsy)--][div class=\'quotetop\']QUOTE(degsy @ Jan 5 2006, 06:25 AM) 333515[/snapback][/div][div class=\'quotemain\'][!--quotec--]

I think you are looking for something similar to

 

<?php if($totalRows_Recordset1 > 5){ ?>
<p><a href="newslinkpage.php" title="link to news articles pages">More articles</a></p>
<?php } ?>

 

Thanks, this worked wonderfully. Now if you happen to know the right way to bring up stuff from LAST MONTH.. a sort of CURDATE() -1 ........

 

Meantime I'm off to read the PHP Manual - Again!!

 

:)

 

Joss

 

 

 

Link to comment
Share on other sites

[!--quoteo(post=333563:date=Jan 5 2006, 08:26 AM:name=sgiandhu)--][div class=\'quotetop\']QUOTE(sgiandhu @ Jan 5 2006, 08:26 AM) 333563[/snapback][/div][div class=\'quotemain\'][!--quotec--]

Meantime I'm off to read the PHP Manual - Again!!

I found my answer in the SQL manual, and am posting it here for anyone who might be interested:

SELECT * FROM tblNews WHERE MONTH(newsDate) = MONTH(DATE_ADD)CURDATE(),INTERVAL -1 MONTH))

Here's the reference to [a href=\"http://dev.mysql.com/doc/refman/5.0/en/date-calculations.html\" target=\"_blank\"]date calculations[/a]

 

And thanks again, to degsy, for pointing me in the right direction

Joss

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.