sgiandhu Posted December 12, 2005 Share Posted December 12, 2005 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 Quote Link to comment https://forums.phpfreaks.com/topic/3030-show-link-if/ Share on other sites More sharing options...
degsy Posted January 5, 2006 Share Posted January 5, 2006 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 Link to comment https://forums.phpfreaks.com/topic/3030-show-link-if/#findComment-10618 Share on other sites More sharing options...
sgiandhu Posted January 5, 2006 Author Share Posted January 5, 2006 [!--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 Quote Link to comment https://forums.phpfreaks.com/topic/3030-show-link-if/#findComment-10626 Share on other sites More sharing options...
sgiandhu Posted January 5, 2006 Author Share Posted January 5, 2006 [!--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 Quote Link to comment https://forums.phpfreaks.com/topic/3030-show-link-if/#findComment-10629 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.