Database Forum
Web Database Register Members List Calendar FAQ

 
Go Back   Database Forum > Database Management > MySQL Database Management
User Name
Password

Reply
 
Thread Tools Search this Thread Display Modes
Default Mysql - Simple Select All Question
07-25-2012, 08:59 AM #1  

katty.jonh
Junior Member

 
Status: Offline
Posts: 2
Join Date: Jul 2012

Hey there guys, I'm trying to select all the rows where a certain ID is: the problem is the query is only returning the first row with the ID. Kinda clueless here, would appreciate any help.

"SELECT * FROM players WHERE acc_id = '$acc_id'";

Using mysql_fetch_array() , I only have the first listed row with the account ID in the array but there is about 5 in the table.

It's selecting all the data from that first row, and I'm guessing that I'm using the wrong query, I'd really like to avoid writing a loop to go through all these queries as I'm sure there is a way to do it with just a single query.
Reply With Quote

Default Re: Mysql - Simple Select All Question
07-25-2012, 09:05 AM #2  

nimolccd
Junior Member

 
Status: Offline
Posts: 2
Join Date: Jul 2012

mysql_fetch_array only returns one row. You need to call it multiple times to get the rest of the rows. This is typically done with a while loop:
while ($row=mysql_fetch_array($res)){
//do something
}

Nimol
Programmer
Corbin Creative Databases, LLC
http://www.corbincreative.com
Reply With Quote

Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump



All times are GMT -5. The time now is 09:50 AM.

Powered by: vBulletin Version 3.7.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Database Forums

Help support our forum assistants and product development ->

go to top go to top