I have a parent class which is loading the data from Dataset. Child class is accessing the values and printing them in a table. There are 10 rows with name, surname and more. I would like to sort name values when someone click on name <th>
using plain php without any javascript or mysql.
Here is my code
$table = "<table border='1'>" .
"<tr>" . "<th>" . "ID" . "</th>";
"<th>" . "<button id='name'>" . "Name" . "</button>" . "</th>" .
"<th>" . "Surname" . "</th>" .
"<th>" . "Active" . "</th>" .
"<th>" . "Last Login" . "</th>" .
"<th>" . "Picture" . "</th>" .
"<th>" . "<button id='rating'>" . "Rating" . "</button>" ."</th>" . "</tr>";
echo $table;
//showing the data in rows
foreach ($user_data as $data) {
echo "<tr>" . "<td>" . $data->id . "</td>";
echo "<td>" . $data->name . "</td>";
echo "<td>" . $data->surname . "</td>";
echo "<td>" . $data->active . "</td>";
echo "<td>" . $data->last_login . "</td>";
Note: I don't want to introduce new loop. I want to stay in one loop.