arminvit Posted January 3, 2007 Share Posted January 3, 2007 Hello, I'm a PHP beginner, and I have one question that might be very easy for this forum... I have this code that numbers my comments on a blog. It does so going in ascending order [b]1 2 3 4 5 ...[/b] and I would like it to change the numbering to descending order [b]... 5 4 3 2 1[/b].[code]<?php $i = 1; ?><MTEntries>...<?php $i++;?></MTEntries>[/code]And this, down here, is what renders the numbers:[code]<?php echo $i; ?>[/code]Is there a simple tweak to this?Thanks!Armin Quote Link to comment https://forums.phpfreaks.com/topic/32693-numbering-changing-sort-order/ Share on other sites More sharing options...
ToonMariner Posted January 3, 2007 Share Posted January 3, 2007 for ($i = 5; $i > 0; $i--){ echo $i;}ALTERNATIVELY sort your blog entries in DESC order in your query. Quote Link to comment https://forums.phpfreaks.com/topic/32693-numbering-changing-sort-order/#findComment-152139 Share on other sites More sharing options...
arminvit Posted January 3, 2007 Author Share Posted January 3, 2007 Toon,Thanks for the quick reply... The descend order changes does change the order of the entries but the numbering stays the same. From your example, is there a way to not have to hard-code how many entries there are? So, instead of [b]$i = 5;[/b] can you make the [b]5[/b] be an automatically growing number depending on the amount of entries so that as new ones come in, the top one changes to [b]6 7 8 9 10 ...[/b] ? Quote Link to comment https://forums.phpfreaks.com/topic/32693-numbering-changing-sort-order/#findComment-152155 Share on other sites More sharing options...
ToonMariner Posted January 3, 2007 Share Posted January 3, 2007 post your query that grabs the blog entries.... Quote Link to comment https://forums.phpfreaks.com/topic/32693-numbering-changing-sort-order/#findComment-152166 Share on other sites More sharing options...
arminvit Posted January 3, 2007 Author Share Posted January 3, 2007 [code] <?php $i = 5; $i > 0; ?> <MTEntries sort_order="descend"> <div class="number_green">No. <?php echo $i; ?></div> <$MTEntryBody$> <div class="quipped_by">POSTED BY <$MTCommentAuthorLink default_name="Anonymous"$ show_email="1" spam_protect="1" regex="1" apply_macros="1"$><MTCommentAuthorIdentity></div><div class="quipped_on"><$MTCommentDate format="%b.%d.%Y"$></div> <?php $i--;?> </MTEntries>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32693-numbering-changing-sort-order/#findComment-152198 Share on other sites More sharing options...
craygo Posted January 3, 2007 Share Posted January 3, 2007 Are your blogs coming from a database?? Quote Link to comment https://forums.phpfreaks.com/topic/32693-numbering-changing-sort-order/#findComment-152207 Share on other sites More sharing options...
arminvit Posted January 3, 2007 Author Share Posted January 3, 2007 Just from MovableType... Quote Link to comment https://forums.phpfreaks.com/topic/32693-numbering-changing-sort-order/#findComment-152235 Share on other sites More sharing options...
arminvit Posted January 4, 2007 Author Share Posted January 4, 2007 And if this helps... The comments themselves here are in the right order, but the numbering is wrong.[url=http://www.underconsideration.com/random/php_numbers.gif]http://www.underconsideration.com/random/php_numbers.gif[/url] Quote Link to comment https://forums.phpfreaks.com/topic/32693-numbering-changing-sort-order/#findComment-152574 Share on other sites More sharing options...
Jessica Posted January 4, 2007 Share Posted January 4, 2007 I think the Movable Type is doing stuff...it's rearranging them. Where is the actual query. It should look similar to:"SELECT * FROM tablename"MT should have an option to do this somewhere, you shouldn't need to mess with the code. Quote Link to comment https://forums.phpfreaks.com/topic/32693-numbering-changing-sort-order/#findComment-152597 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.