I’m building a database driven website using WAMP
I have database with table called userinfo with the following field names DateTime DomainName ComputerName UserName NetworkSettings.
And I have a PHP script with a HTML table
echo "<div id='tableheading'>\n";
echo "<table class='data' border='1'align='center'>\n";
echo "<tr>\n";
echo "<th> DateTime </th>
echo "<th> DomainName </th>
echo "<th> ComputerName </th>
echo "<th> UserName </th>
echo "<th> NetworkSettings </th>
How do I get the field names straight from the database?
As you are using WAMP, I assume you're talking about MySQL. Have a look at mysqli_result::fetch_fields().
I'd advise against that
- It's better to give field names plain lowercase names
- HTML table headers often mismatch db table field names
- Typing field names by hand is not as hard as you imagine
精彩评论