简体   繁体   中英

Why does this query return different values?

I'm trying to pull information from my database, but the query I'm using is only pulling all of the values after the first one. I have no LIMIT set, but I did try setting a LIMIT 0,30 with no change. In phpMyAdmin, the query returns what I expect. In my PHP file, it returns what I've explained.

The query is :

SELECT * FROM `mainSite_others` WHERE forGame='$gameName'

gameName is previously provided, and I suspect no errors because it does return at least two values. The forGame value in the database is all the same, a constant "+Stellar+Dawn" .

The PHP code is:

while ($gameOther = $database->fetchArray($gameOtherQry)) { 
    echo $gameOther['otherName'];
}

Don't worry about the $database->fetchArray part, that is just my DB class, which works fine as far as I know.

The table I am extracting from looks like this (this is with all the values contained):

id    |    forGame    |   otherType    |   otherName    |    otherDesc
9     | +Stellar+Dawn | Character      | Car            | Car
10    | +Stellar+Dawn | Item           | Brugson Burson | a guy
11    | +Stellar+Dawn | Item           | Space Pie      | A pie from space

I am using mySQLi.

Any ideas? Thank you.

在到达while循环之前,您可能正在进行访存调用,这会“丢失”结果的第一行。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM