2

I have tried with sort() in front of $new but it won't work, where should I put it?

$new = mysql_query("SHOW COLUMNS FROM Professors");

   while($row = mysql_fetch_array($new)) {  

    $output .= "{$row['Field']}";
    echo $output;
}

I have also tried something like this:

  $new = "SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE   table_name = 'Professors' ORDER BY column_name";

but, while on my SQL compiler it will sort them correctly, they won't get printed on the page with the exact code above.

Prafulla Kumar Sahu
  • 9,321
  • 11
  • 68
  • 105
Fidelio
  • 174
  • 12

1 Answers1

0

Try this, then:

 $new = "SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE   table_name = 'Professors' ORDER BY column_name";

   while($row = mysql_fetch_array($new)) {  
    $output = $row['column_name'] . "<br>";
    echo $output;
}

You were ordering it correctly and selecting by column name but you weren't getting the correct field names.

Phiter
  • 14,570
  • 14
  • 50
  • 84