SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SQL Order By displaying incorrectly

    Hey,

    I have a SQL statement which selects a number of fields from a table, and puts them in order of the unique id DESC. I am trying to show the latest fields first..

    My select statement is shown:-

    PHP Code:
    SELECT pic_idimage_namecaption FROM images WHERE image_name != '' ORDER BY pic_id DESC 
    Now when i read out the results, for some reason it is displaying incorrectly. The SQL statement works fine, it pulls out the data i want, but when it comes to displaying it the problem arises, you can view this here:-

    http://www.loumolloy.com/gallery.php

    One reason why i have asked this question here is becuase if i change the SQL ORDER BY statement to ASC, then the images display perfectly..

    But thats not what i want, so when changing it to DESC, the images do not appear in perfect rows, you will know what i mean when you view the page.

    Is this a common problem or have i missed something out?

    Regards

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    It's your styling that's doing it, to prove it, remove the description for the Apprentice guy.

    Au Voila!
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    You're right it is the styles, i have tried making the width of the <div> element bigger but it does not seem to be having an effect..

    My styles for this are:-

    PHP Code:
    .gallery {overflow:hidden;width:860px;margin:auto;margin-top:10px;}
    .
    gallery div {float:leftwidth:170pxmargin:auto;padding-bottom:25px;text-align:center}
    .
    gallery div img {display:block;border:2px solid #c0c0c0;margin:auto;}
    .gallery div span{font-size:11px
    I know this is not a styles forum, but i dont see why its doing this..

    Is there a quick fix for this problem?

    Regards

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    You could add a height the div's wrapping the gallery entries, but your css selector covers the pagination div also so this would need to be addressed.

    Add 'Height: 100px' to .gallery div
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  5. #5
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats great,

    Works fine now.

    Cheers

  6. #6
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Anytime, although do try to limit the non-PHP questions for me.

    It saves me from making the answers up.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.


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
  •