Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL Starting from a certain value
    text
    copied!<p>I have a mysql table with unique id's, and I'm displaying them in an html table. For those who are curious, here's the code.</p> <pre><code>&lt;?php require_once '../page.php'; require 'checklogin.php'; $page = new Page(); $page-&gt;title = 'View Students'; $page-&gt;sidebarliab = true; $lastvari; $id = $_GET['id']; echo $id; // Connect to database $con = new mysqli($mysqlurl, $mysqlusername, $mysqlpassword, $mysqldatabase); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // Prepare to select all students $stmt = $con-&gt;prepare("SELECT Last_Name, First_Name, Student_ID FROM Students LIMIT 30"); $stmt-&gt;execute(); // Execute the query $stmt-&gt;bind_result($last_name, $first_name, $student_id); // Bind variables to the result of the query ?&gt; &lt;h2 style='margin-left:1%'&gt;All Students&lt;/h2&gt; &lt;table id='liabilityTable'&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Last Name&lt;/th&gt; &lt;th&gt;First Name&lt;/th&gt; &lt;th&gt;Student ID&lt;/th&gt; &lt;th&gt;Homeroom&lt;/th&gt; &lt;th&gt;Number of Liabilities&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;?php while($stmt-&gt;fetch()) { echo "&lt;tr&gt;"; ?&gt; &lt;td&gt;&lt;?=$last_name?&gt;&lt;/td&gt; &lt;td&gt;&lt;?=$first_name?&gt;&lt;/td&gt; &lt;td&gt;&lt;?=$student_id?&gt;&lt;/td&gt; &lt;?php echo "&lt;td&gt;&lt;/td&gt;"; echo "&lt;td&gt;&lt;/td&gt;"; echo "&lt;/tr&gt;"; $lastvari = $student_id; } $stmt-&gt;close(); // Close the statement $con-&gt;close(); // Close connection to database ?&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;a href=&lt;?php echo "students_view.php?id=$lastvari"; ?&gt;&gt;&lt;button type="button"&gt;Next Page&lt;/button&gt;&lt;/a&gt; </code></pre> <p>So basically, that's a table. I want to be able to click the top row and be able to organize it alphabetically (say clicking last name would organize by last name, clicking ID would be numerically, etc. just like in windows explorer). Does anybody know how I would be able to do this? Either a solution or just being pointed in the right direction would be absolutely fantastic.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload