• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

Populating a Table with the Results of a Recordset

Hi All,
I want to populate a table on the main page with the contents of a certain data-field from the database. I can get the result to display, my only problem is I want each cell to contain one field (from the RS) and I want the table formatted so that it has 3 cols and has a varying amount of rows based on the result of the query. I also need to make the width and height of each cell an exact side (the same size each time).
Thanks,
D
0
dereksheahan
Asked:
dereksheahan
  • 4
  • 2
2 Solutions
 
RouchieCommented:
In ASP, something like this...

<table>

   <%
   WHILE NOT RS.EOF %>

       <tr>
         <td><%=RS("Field1")%></td>
         <td><%=RS("Field2")%></td>
         <td><%=RS("Field3")%></td>
       </tr>
       <tr>
         <td><%=RS("Field4")%></td>
         <td><%=RS("Field5")%></td>
         <td><%=RS("Field6")%></td>
       </tr>

   <%
   RS.MOVENEXT
   WEND
   %>

</table>


To do the sizing of the table cells, use style sheets - its much easier.
<head>
<style type="text/css">
   td {height: 30px; width: 100px;}
</style>
</head>
0
 
dereksheahanAuthor Commented:
Hi Rouchie,
I'm using PHP 5, I wonder is it a similar syntax. Sorry, forgot to mention that :)
0
 
RouchieCommented:
Well... the style sheet is the same ;-D

I'd wait for jason1178 to take a look.  He's the pro with PHP!
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
dereksheahanAuthor Commented:
Thanks Rouchie, I'll start on the style sheet so!!
0
 
Jason C. LevineNo oneCommented:
Rouchie,  

Wow.  Thanks for the praise...

I'd like to take this moment to thank all of the little people who made this possible. <crickets>

Okay, back to Derek.

When you say each cell contains one field, three cols and vary rows to the end of the query results, do you mean the field is the same (like a cell phone) each time and you want the repeat region to go horizontal first then vertical?

If so, this is called horizontal looping and it isn't the easiest thing to do by hand.  Fortunately, Tom Muck of DW team is a nice guy and has written a free behavior for this for both PHP and ASP.  Read the tutorial and then download the behavior at the bottom of the page:

http://www.tom-muck.com/extensions/help/HorizontalLooper/

It's super simple to use.
0
 
dereksheahanAuthor Commented:
Yes, thats exactly what I mean. Thanks Jason, I'll check out that behaviour when I get back from break :)
0
 
dereksheahanAuthor Commented:
Brilliant! Got that working spot on!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now