"; } $result = mysqli_query($cxn,$query) or die ("Couldn't execute query"); echo "Click ID# to edit.
Click ColumnName to sort."; echo "
"; /////////////////CREATE HEADER OF TABLE/////////////////// for($i = 1; $i < mysqli_num_fields($result)+1; $i++) { //runs for number of columns, from 1 to +1 to be able to multiply by -1 $field = mysqli_fetch_field($result); /////////SET BUTTON STATUS//////////////// if (isset($_POST['hidden'.$i])){ //check wether button was pressed before if ($_POST['hidden'.$i] == 0) { //if button pressed first time, set ASC $buttonvalue = 1; } else { //if button pressed before, toggle ASC-DESC $buttonvalue = $_POST['hidden'.$i] * -1; } } else { $buttonvalue = 0; //set default state button, not sorted } /////////////////////////////////////////// ///////////////PRINT HEADER & BUTTONS/////////////////// echo ""; //////////////////CREATE DATABASE TABLE////////////////////////// while ($row = mysqli_fetch_assoc($result)) { //draw data from database foreach($row as $value) { $count++; //registrate count to break table at end of databaserow ///////////////// if($count == 1) { echo ""; } if($count > 1 && $count <= mysqli_num_fields($result)){ echo ""; } if ($count == mysqli_num_fields($result)){ //count to the number of columns, next row echo ""; $count = "0"; } } } echo "
\n \n"; for ($j=1; $j
".$value."
"; //echo "
"; mysqli_close($cxn); ?>