#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    5
    Rep Power
    0

    Select Where (one entry is missing)


    Hi and hello first :-)

    This is my code:
    PHP Code:
                $result mysql_query("SELECT * FROM `pk_database` WHERE `group` LIKE '$lp' GROUP BY id DESC") or die(mysql_error());  
                
    $row mysql_fetch_object$result );
                
                while(
    $row mysql_fetch_object$result )) {
                                
    $imgshort explode("="$row->link);
                                
                                echo 
    "<section class=\"portfolio-item portfolio_4 grid_3\">";
                                echo 
    "<a class=\"portfolio-image round-3\" href=\"".$row->link."\" title=\"View fullsize\" rel=\"prettyPhoto\">";
                                echo 
    "<span class=\"portfolio-image-inner\">";
                                echo 
    "<img src=\"xxx"$imgshort[1] ."/mqdefault.jpg\" width=\"210\" height=\"130\" alt=\"Item one\" />";
                                echo 
    "</span>";
                                echo 
    "</a>";
                                
                                echo 
    "<h2><a href=\"#\" title=\"Project name\">"$test ."</a></h2>";
                                
                                echo 
    "</section>";
                } 
    In this database are 4 entrys! That tell me the count! But he shows my only 3 entrys. The FIRST entry are not shown by this way.

    For example:
    Entry 1: id=1 name=name1 group=group1
    Entry 2: id=2 name=name2 group=group2
    Entry 3: id=3 name=name3 group=group3
    Entry 4: id=4 name=name4 group=group4

    He only shows me Entry 2, 3, 4 but not 1!

    WHY? THX!
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Hi,

    why do you even have a WHERE clause if you want all rows?

    The whole purpose of this clause is to only select certain rows. And appearently that worked very well: You only got the rows that match your $lp pattern (whatever that looks like).
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    5
    Rep Power
    0
    I have a huge database with over 550 entrys! I only want the entry with the group="test" for example. All informations of the entrys with group="test".
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,441
    Rep Power
    1688
    Not any good at php, but:

    Code:
                $row = mysql_fetch_object( $result );
                
                while($row = mysql_fetch_object( $result )) {
    Won't that get the first row of the results, then throw it away as soon as the while is executed and replace with the next row?

    Comments on this post

    • E-Oreo agrees
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    5
    Rep Power
    0
    What should i do? Oo
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    867
    Rep Power
    275
    try starting with $imgshort[0] instead of $imgshort[1]
    on this line
    PHP Code:
    echo "<img src=\"xxx"$imgshort[1] ."/mqdefault.jpg\" width=\"210\" height=\"130\" alt=\"Item one\" />"
  12. #7
  13. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    You should remove your first call to mysql_fetch_object so that you don't burn the first result.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  14. #8
  15. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Originally Posted by Kampfschaf
    I have a huge database with over 550 entrys!
    Totally off topic, but that made me laugh.

    Comments on this post

    • paulh1983 agrees : spelling mistake or the huge "550" records :p
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    5
    Rep Power
    0

    Thumbs up


    Originally Posted by E-Oreo
    You should remove your first call to mysql_fetch_object so that you don't burn the first result.
    THX that works fine :-)
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    5
    Rep Power
    0
    Originally Posted by Jacques1
    Totally off topic, but that made me laugh.
    For me it is huge :-) Because i manualy added them over month ^^

IMN logo majestic logo threadwatch logo seochat tools logo