Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2010
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question about tables

    So I have a table with 6 columns and about 200 rows. The odd numbered rows all have cells with 60X60px images and all the even numbered rows have text. (so the first row has a picture and then under the picture is the name of the image). Everything must be ordered alphabetically. The problem is
    that each time I want to add a new image I have to edit most of the coding. Is there a way to align tables in columns of six alphabetically without having to redo the most of the code each time? like maybe there is some type of script I can use? or is there an easier way to code it?
    The code looks like this
    <table border="1" bordercolor="#000000" cellpadding="0" width="450px">
    <tr>
    <td><img src=""></td>
    <td><img src=""></td>
    <td><img src=""></td>
    <td><img src=""></td>
    <td><img src=""></td>
    <td><img src=""></td>
    </tr>
    <td>Name of the image</td>
    <td>Name of the image</td>
    <td>Name of the image</td>
    <td>Name of the image</td>
    <td>Name of the image</td>
    <td>Name of the image</td>
    </table>

  • #2
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,335
    Thanks
    5
    Thanked 363 Times in 360 Posts
    Have you considered using a database and server side language to query and display these images and titles dynamically? Much easier and much less headache.

  • #3
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,915
    Thanks
    15
    Thanked 227 Times in 227 Posts
    It's very easy to automate the construction of tables with javascript, PHP or just about any language around. You put all the data in an array, which is very easy to write and edit, and a simple function takes the data and puts it in a table. Here's an example of a page using that.

    http://ronbeau.50webs.com/utilities/escape-codes.html

    You code will need to be a bit more sophisticated than that since it has to alternate rows. I would suggest putting the image and text in the same item in the array and using the split/explode function to separate them to simplify editing the array.

  • #4
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    I think the terms split and explode will have exactly that effect on the OP. lol

    Basically you can learn a bit of javascript or better (in the medium and long-term), learn a server-side language. that will enable you to automate a lot of what you are tyring to do and make ongoing management easier.

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •