SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Sep 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help me find Logical error in this php code

    I have written a class for printing mysql query result to html table. There is no syntex error. it works very file. but there is one logical error. and that is in htmltable function. It prints one row less than the actual rows. it misses the very first row which is to be printed. error may be somewhere around while loop. please help me find the error. I tested it in all possible ways from my side.

    code is available at pastebin

    http://pastebin.com/uvcqkyun

    Thanks

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    You made a very easy mistake, you are calling mysql_fetch_assoc() prior to your while loop, which moves the cursor to the next row, instead use mysql_field_name.

    Pastebin updated: http://pastebin.com/vLxvwkkp
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  3. #3
    SitePoint Member
    Join Date
    Sep 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks cpradio
    Issue resolved. I was struggling all round while loop.
    It was a simple class to display to result to html table using class. I wanna extend it now.
    Possible addition may be.
    1. Adding extra clickable column to table rows action queries.
    2. Adding alternate row css class for alternate row colors.
    3. Table header row css class for styling.

    and may be few other functions so that this class can be used in almost any project. All forum members are invited to suggets or contributes to this generic class. It may be useful to many.


Tags for this Thread

Bookmarks

Posting Permissions

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