Jump to content

Numbering - Changing sort order


arminvit

Recommended Posts

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
Link to comment
Share on other sites

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] ?
Link to comment
Share on other sites

[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]
Link to comment
Share on other sites

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