Populating a Table with the Results of a Recordset

Posted on 2006-05-09
Last Modified: 2010-04-25
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).
Question by:dereksheahan
    LVL 25

    Assisted Solution

    In ASP, something like this...


       WHILE NOT RS.EOF %>




    To do the sizing of the table cells, use style sheets - its much easier.
    <style type="text/css">
       td {height: 30px; width: 100px;}

    Author Comment

    Hi Rouchie,
    I'm using PHP 5, I wonder is it a similar syntax. Sorry, forgot to mention that :)
    LVL 25

    Expert Comment

    Well... the style sheet is the same ;-D

    I'd wait for jason1178 to take a look.  He's the pro with PHP!

    Author Comment

    Thanks Rouchie, I'll start on the style sheet so!!
    LVL 70

    Accepted Solution


    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:

    It's super simple to use.

    Author Comment

    Yes, thats exactly what I mean. Thanks Jason, I'll check out that behaviour when I get back from break :)

    Author Comment

    Brilliant! Got that working spot on!

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
    Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now