Link to home
Start Free TrialLog in
Avatar of David Megnin
David MegninFlag for United States of America

asked on

How to create an HTML table from a SQL Database

On our public web page we have a "Board Membership" list page with about 60 Board Members listed with their title, organization, web page and board position.  We also have a "Staff Directory" that just lists 50 or so staff by name, job title and telephone number.

The lists are updated frequently and are in the form of simple HTML tables.  See formats below.  I currently update them by just editing the HTML tables in notepad and pasting the html into the appropriate content block.  Our web site is hosted by a third party and I can't use ASP.Net, only HTML.  I may be able to get away with some imbeded JavaScript, but I can only edit content between the <body></body> tags, the <head> is in a master page I don't have access to.

What I'd like to do is maintain the list of board members and info in a SQL table and the list of staff and phone numbers in another SQL table and generate the HTML table from the database.  That way I can provide a data input form for the secretary to update the lists and I can generate the table and post it very quickly.

I don't need to have the html table automatically posted to the web site I just need to generate an HTML table in a local text file from our local SQL table.  Then I can just copy it to our web site on the appropriate page.  Any method of generating a pain vanilla html table is fine.  If it requires  ASP.Net/VB/JavaScript/XML or whatever, as long as the output is a plain html table in a format like below.

Thanks!
Board Membership Table format (repeat 60 times):
                <tr>
                    <td>
                        <span style="font-weight:bold;">FirstName LastName</span><br />
                        <em>Title</em>
                    </td>
                    <td>
                        <a target="_blank" href="http://www.webpage.com"><strong>Organization</strong></a>
                    </td>
                    <td>
                        <strong>Position</strong>
                    </td>
                </tr>

Staff Directory Format (repeat 50 times):
                <tr>
                    <td><a href="mailto:Username@AlwaysSameDomain.com">&nbsp;FName LName</a><br />
                    Job Title</td>
                    <td>954.202.1234, x3056</td>
                </tr>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Todd Gerbert
Todd Gerbert
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of David Megnin

ASKER

Nice!  I have two exciting looking options to play with tomorrow.
tgerbert, thank you.  Yes, my goal is to keep it as simple as possible.  Any more difficult than changing a row or two in an HTML table ever other month or so and I'd just keep updating what we have.  Your C# example looks like just the ticket.  I only work with VB for now, but it should be a simple matter to convert that to VB.
emoreau, that LINQ and XML Literals example looks a little more complicated, but it's already in VB, I want to learn to use LINQ anyway and it looks like that technique could be very useful now and in the future.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Nice, Dan.  Thank you.  That solution looks very good as well.  I've been tied up today doing the typical Monday, urgent but unimportant tasks and haven't had a chance to play with these yet.  I've still got a few hours to go today so hopfully I can get started in a little bit...
Thany you very much for the excellent solutions.