Hi guys,
I have a quick and interesting question there for you:
I have my DB and a execute a query to read some data from the DB and return it to the HTML.
The data that is returned depends on the search fields the user had filled in.
So if he had only filled lets say Experience and rating out of several possible fields, the query would produce a table containing just these two parameters.
Now, when I fetch my result, I want to read the names of the columns that the query returned, in order to write them in the html as table headings. How do I do this?
Here simple structure of what I mean:
resultSet resQuery = null;
resQuery = stmt.executeQuery(searchQuery);
if( resQuery != null ) {
out.println("<TR>");
try{
while(resQuery.next()) {
out.println("<TD>" + resQuery.[I]getNext()[/I] +"</TD>");
}
out.println("</TR>");
// and then when the HTML table has the appropriate headings, let the values flow into the table
while(resQuery.next()) {
String resKname = null;
String resTalent = null;
String resStyle = null;
String resInstrument=null;
int resExperience=0;
..............
out.println("<TR><TD><b>"+resKname+"</TD><TD>"+resTalent+"</TD><TD>"+resStil+"</TD>......
}
This shouldn't be that difficult?