Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Column Names AND Data 1

Status
Not open for further replies.

jammer1221

Programmer
Jul 30, 2003
352
US
Hi all,

I was having some trouble with this one, and was wondering if anyone had an easy answer.

I'm trying to get all the column names in a row. And then get the data for each row. I can do both of these seperatly.

The problem I am having is that I need to check whether or not the column has data in it for that row and if not I need to not include it, into the output varible.

I don't know if this has a blindingly simple answer, or if its impossible but I've been working on it forever. Sorry if the above is a little confusing, I tried to explain it the best I could. Well thanks for the help in advance.

Matt
 
Oh ya, this is all in a MySql database...Left that out, it might help.
 
mysql_fetch_assoc() fetches data from a MySQL result handle into an associative array. There's column names and values all at once.

If you want to get all the columnnames first, issue a DESCRIBE tablename query and fetch the results of that query. This will give all the information you will ever need about your table, and you can follow that query with a SELECT query.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Hey sleipnir,

Thanks for the help I got on the right track with your post. I didn't know/think about a "Describe
" query.

Thanks again,
Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top