R
R
rechmp2013-04-01 16:22:40
PHP
rechmp, 2013-04-01 16:22:40

how to display mssql table header in php

Good afternoon.
It was necessary to display a table on the page along with the title, preferably in one request.
Can you tell me how?
If one is not possible, then how is it better?
Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
Oleg Matrozov, 2013-04-02
@Mear

About clarification:
You stubbornly do not want to look at PHP help. I cited the mssql_field_name function as an example, and, lo and behold, there is a one-to-one function with the name ... drum roll ... odbc_field_name which also returns the names of the columns based on the result of a query to the database.
Sorry, of course, but it's time for you to start fighting your own laziness.

S
Slipeer, 2013-04-01
@Slipeer

If you use mysql_fetch_assoc , then you can make one query:

$res = mysql_query('select a, b, c from foo');
$row = mysql_fetch_assoc($res);
print '<table><tr>';
foreach($row as $name => $value) {
    print "<th>$name</th>";
}
print '</tr>';
while($row) {
    print '<tr>';
    foreach($row as $value) {
        print "<td>$value</td>";
    }
    print '</tr>';
    $row = mysql_fetch_assoc($res);
}
print '</table>';

I didn't take my example from here.

O
Oleg Matrozov, 2013-04-01
@Mear

SHOW FULL FIELDS FROM <table>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question