Jump to content

Trying to sort by number in string


onjegolders
 Share

Recommended Posts

Hi guys, I'm running into a few issues trying to use my sorting dropdown on a table to play nicely with digits in a string.

My table currently has a total as one of its columns and I have created a select dropdown to choose the sorting method:

<form action="./" method="post">
            <select name="sort" onchange="form.submit()">
              <option value="title">Sort by...</option>
              <option value="title">Invoice number A-Z</option>
              <option value="-title">Invoice number Z-A</option>
              <option value="invoice_total">Invoice Total A-Z</option>
              <option value="-invoice_total">Invoice Total Z-A</option>
              <option value="invoice_status">Invoice Status A-Z</option>
              <option value="-invoice_status">Invoice Status Z-A</option>
              <option value="invoice_client">Client Name A-Z</option>
              <option value="-invoice_client">Client Name Z-A</option>
              <option value="invoice_date">Invoice Date A-Z</option>
              <option value="-invoice_date">Invoice Date Z-A</option>
            </select>
        </form>
<?php foreach ($page->children("sort={$input->post->sort}") as $invoice) { ?>

I've just realised that it will struggle to sort my invoice_total as I believe it may need natsort() applying to it. The problem is when I try this, it seems to completely empty the pageArray.


Could anyone give me a pointer? Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...