By the by, not relevant to JS or HTML coding, but...
It's a bad idea to do this:
$sql="SELECT * FROM Complex ORDER BY Name" . $num;
(and what is the $num there for, by the by?)
You really should never use SELECT *
if you can help it.
In this case, you clearly know the fields from the table that you need for this page, so:
$sql = "SELECT Key_ID, Name, Address1, Address2, City, State, Zip "
. " FROM Complex ORDER BY Name";