Jump to content


Photo

Show link if....


  • Please log in to reply
3 replies to this topic

#1 sgiandhu

sgiandhu
  • Validating
  • PipPip
  • Member
  • 13 posts
  • LocationVancouver, B.C. Canada

Posted 12 December 2005 - 04:38 PM

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

#2 degsy

degsy
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 05 January 2006 - 02:25 PM

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 } ?>


#3 sgiandhu

sgiandhu
  • Validating
  • PipPip
  • Member
  • 13 posts
  • LocationVancouver, B.C. Canada

Posted 05 January 2006 - 04:26 PM

[!--quoteo(post=333515:date=Jan 5 2006, 06:25 AM:name=degsy)--][div class=\'quotetop\']QUOTE(degsy @ Jan 5 2006, 06:25 AM) View Post[/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 } ?>
[/quote]

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




#4 sgiandhu

sgiandhu
  • Validating
  • PipPip
  • Member
  • 13 posts
  • LocationVancouver, B.C. Canada

Posted 05 January 2006 - 05:24 PM

[!--quoteo(post=333563:date=Jan 5 2006, 08:26 AM:name=sgiandhu)--][div class=\'quotetop\']QUOTE(sgiandhu @ Jan 5 2006, 08:26 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Meantime I'm off to read the PHP Manual - Again!!
[/quote]
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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users