View Single Post
Old 02-02-2013, 10:26 PM   PM User | #1
Eggweezer
New Coder

 
Join Date: May 2012
Posts: 97
Thanks: 75
Thanked 0 Times in 0 Posts
Eggweezer is an unknown quantity at this point
Trying to create a hyperlink

I am pulling data from a database and displaying it in a simple table.
My goal is to figure out how to be able to click on one of the 2 table headers, and make the page reload, sorting on the column selected.

I am first of all trying to figure out to make the headers into "hyperlinks". I cannot figure it out.

Here is my code, and I would appreciate any help or advice. Thank you.

Code:
        // get results from database 
        $result = mysql_query("SELECT * FROM mytable ")  
                or die(mysql_error());   
                 
        // display data in table                
        echo "<table border='1' cellpadding='10'>"; 
        echo "<tr><th>Last Name</th><th>First Name</th></tr>"; 

        // loop through results of database query, displaying them in the table 
       	$count= 0;
	    while($row = mysql_fetch_array( $result )) { 
        ++$count;
		
	  
	  // echo out the contents of each row into a table 
	             echo "<tr>";
				 echo '<td width="100">' . $row['nameLast'] . '</td>';
				 echo '<td width="100">' . $row['nameFirst'] . '</td>';
                 echo "</tr>";   
        }  

        echo "</table>"; 
?>
Eggweezer is offline   Reply With Quote