im fairly new to php. actually, this is the first project that i have ever done in php, so im learning as i go here, and while the web and some books have been a lot of help, i have come to a problem that i am not sure how to solve.
the problem is something like this:
im starting to understand the power of php, and since php can generate the html code, i know that you can create many pages from one page of php. so im working on a database site, and im about done with all of the admin control pages, and i want to create a page to view all of the current users.
i understand how to get data from the database and display it, thats easy. my question is, say i have all of this data, say user name, first name, and last name, and i want to display all of these columns. now if i want to be able to sort by any of these columns, what do i do so that i am not creating a page for sorting the user name, a page for sorting the first name, and a page for sorting the last name?
im guessing that i should just create functions that do all of these, and put them all in the same page, then just wait for the user clicks and call the right function. basically, it will just be a decent sized php script with 3 or 6 functions, a function for sorting alphabetically or in reverse alphabetical order for each column.
something like this:
<?php
function alphabet_user_name()
{
...
}
function reverse_user_name()
{
...
}
function alphabet_first_name()
{
...
}
//and so on and so forth
?>
<html>
... page code goes here ...
</html>
is my methodology right? since im so new to this, i dont really know the shortcuts, altho im trying to find them. any help would be appreciated. im not too worried about how to do it, im pretty sure i can figure that out. i just want to make sure that im doing this the "right" way, and that im doing it efficiently.
any help would be appreciated. thanks ahead of time.