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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Database Table in HTML

Status
Not open for further replies.

pcawdron

Programmer
Jun 14, 2000
109
AU
I'm trying to display a database table in HTML using VB Script.

I've set up a script that accesses my database, built a string called sResults that contains HTML formatted table commands, ie.

sResult = &quot;<TR><TD style='font-size: 10pt;'>&quot; & Recordset.field(0) & &quot;<TD>&quot;

sResult = sresult & &quot;<TD style='font-size: 10pt;'>&quot; & Recordset.field(1) & &quot;</TD></TR>&quot;


Then I've placed the following...


<BODY>
<TABLE border=&quot;1&quot;>
<TR>
<TD><B>Column1</B></TD>
<TD><B>Column2</B></TD>
</TR>
<%=sResults>
</TABLE>
</BODY>
</HTML>


But it wont show the results from the recordset. The column headers come up, but, outside the table, the string <%=sResults> appears, as is.

I'm new to HTML, so please forgive my ignorance - but I can't figure out what I'm doing wrong.

Thanks for your help
 
pCawdron,

Are you sure that your VBScript is right?
Try the following:

sResult = &quot;<TR><TD style=&quot;&quot;font-size: 10pt&quot;&quot;>&quot; & Recordset.Fields(&quot;FieldName0&quot;) & &quot;<TD>&quot;

sResult = sresult & &quot;<TD style=&quot;&quot;font-size: 10pt&quot;&quot;>&quot; & Recordset.Fields(&quot;FieldName1&quot;) & &quot;</TD></TR>&quot;
Mise Le Meas,

Mighty :)
 
By the way, I presume that you have this in an ASP file or something similar otherwise it will presume that <%=sResult> is just normal text and display it rather than try to resolve it. Mise Le Meas,

Mighty :)
 
Change <%=sResults> to <%=sResults%> (you left off the ending &quot;%&quot;), plus, like Mighty said, this must be an ASP page and not an HTM page.
 
GlennBSI,

Good spot.
I didn't even notice that the closing % was missing. Mise Le Meas,

Mighty :)
 
Yeah, I know how it goes. When you look at code so often, it's easy to miss stuff like that. You just basically assume that it's right because usually, you're looking for something harder to explain.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top