Column Heading for a Query Result

Hello. I have a query that gets information from a MySQL database. I want to be able to put in coloumn headings. I know I can hard code the column headins in but I don’t necessarily want all column headings to appear. For example, one of the results would be restaurants, they have a column called cuisine. I want the cuisine column to appears if restaurant is chosen but if beauty salons is chosen Cuisine will obviously be blank, therefore I want to suppress it. I am very new to php so I don’t know about writing complicated code or if this can even be done. Also, if I do not hard code the column headings, will I later be able to add a script that allows a user to click on a column heading and sort by column heading. I hope that all makes sense. Thanks in advance for any help or guidance!

My query is

$query = “SELECT Business_name, Street, City, State, ZIP, Phone_number, weblink, Denomination FROM clients WHERE Category=”{$_POST[‘Category’]}"";
$result = mysql_query($query,$cxn);
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.     Return To Home Page

print “


while ($get_info = mysql_fetch_row($result))
print “

foreach ($get_info as $field)
print “tn”;
print “n”;
print “


Maybe you’re looking for mysql_field_name()?

Thank you. I will look into using that command in my query.

Sponsor our Newsletter | Privacy Policy | Terms of Service