On 5/15/2013 12:32 PM, Charlie Lewis wrote:
I have a bookseller database list read into a PHP array with dimensions
[row][field]. There are 32 fields in each record/row and up to 500 records.

What is the neatest way to sort the array by any of the fields, such as
author or title?

I know I should just search for a manual on this, but could anybody give me
a quick start?



Sure you can sort this array, but you'd have to write your own I think. Why not just order a query and use those results instead of an array?

A query should process pretty fast on almost any system. Are you in need of such instantaneous response that you thought of going to an array?

You could have this query:

$q = "select author,title,year,media ... from books_table order by '$sortkey'"

where $sortkey can be a desired field name chosen by the user. Could be a multi-fieldname sortkey as well. Could be run as an ajax request if need be too.

So many better ways of doing this than an array IMHO.

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to