Basic question about mysql_fetch_array()

I have a simple database setup for practice and in it, it has 1 column called “id” and it’s set to type INTEGER. In this, I have only 1 number so far: 123.

I wanted to ensure that the database connection was working, so I did the following:

$query = 'SELECT * FROM table';
$array = mysql_fetch_array(mysql_query($query));

The print_r returned something unexpected (from my standpoint, that is). It returned the following:

Array ( [0] => 123 [id] => 123 )

At first, I was confused because I kept thinking to myself that there should only be 1 item returned due to having stored only 1 number in the table. Does MySQL return 2 key/value pairs for each single item queried everything it returns a result set?

For example, if submitting 3 objects to be queried against some miscellaneous table, will it always return 6 result sets, etc? I guess I had originally only expected 1 single data item to be returned from my above example… :confused:

Thanks for any insight into this.

Check out the 2nd (optional) parameter for [fphp]mysql_fetch_array/fphp. :wink:

Well, you get ONE item - ONE array. What else do you want to have. You can use other functions which will give you only alphanumeric indexes or the like but it will be an array nevertheless… you’ll find the alternatives on the php site

Got it guys and thanks. I just missed the second parm for the function…
Feel free to throw a hammer at me. :.)