Re: [rjbathgate] New array from a foreach
Hi rjbathgate,
That's the main concern with your approach, yes: on every search page, you'd need to load all the records from the database.
Depending on the complexity of the totalprice calculation, it may be possible to get MySQL to calculate it for you during the SELECT, allowing you to use it to paginate and sort.
Another option would be a custom plugin which automatically updates a totalprice field whenever a record in that section is saved.
I'd need to see the specifics on how totalprice is calculated to figure out what approaches would make sense.
I hope this helps! Please let me know if you have any questions.
P.S. Rather than pushing the $totalprice and $vehiclenum into your new array, it would probably be better to push the $totalprice and the entire $record into the array -- then you won't need to look anything up by num!
All the best,
Chris