Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works

PhP Help

  • Please log in to reply




  • Member
  • PipPip
  • 37 posts
i need to output the contents of a mysql table into a HTML table with clickable column headings. When a column heading is clicked, the data should be sorted in ascending order by the corresponding field. i have got as far as outputting the table but im not sure how to go about sorting the data.

my code so far is below and any help would be much appreciated.

thanks **Luke**

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Basic Output</title>
<link href="BasicFormOutput.css" rel="stylesheet" type="text/css" />


@mysql_select_db($database) or die( "Unable to select database");

$result = mysql_query("SELECT * FROM datainput") 
or die(mysql_error());  

echo "<table border='1'>";
echo "<tr> <th>Customer ID</th> <th>Name</th>  <th>Address</th>  <th>Postcode</th>  <th>Telephone</th>  <th>E-Mail</th> </tr>";

while($row = mysql_fetch_array( $result )) {
	echo "<tr><td>"; 
	echo $row['customerid'];
	echo "</td><td>"; 
	echo $row['name'];
	echo "</td><td>"; 
	echo $row['address'];
	echo "</td><td>"; 
	echo $row['postcode'];
	echo "</td><td>"; 
	echo $row['telephone'];
	echo "</td><td>"; 
	echo $row['email'];
	echo "</td></tr>"; 

echo "</table>";


  • 0


Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP