Foreach giving (I think) odd results

Hi guys. It has been a while since I last bothered you all with a stupid question so I think it is time for another:

I am querying a db to get the results for a field and then using a foreach to do something with each result.

I have been through many different iterations and experiments to try and get the expected results but have failed.

I will go through it step by step.


$idquery = mysql_query("SELECT id FROM foo WHERE bar=1 ");

If I run this through SQL on myPHPadmin I get


Which is exactly what I want and expect.

Now if I add the following code to the page:

$idrow = mysql_fetch_array($idquery);
foreach ($idrow as $idkey => $idvalue)
echo $idkey." - ".$idvalue;
echo "<br />";

I get:
[COLOR=darkred]0 - 1[/COLOR]
[COLOR=darkred]id - 1[/COLOR]

[COLOR=black]I don’t know what the 0 is (or rather why it is there) and I don’t know where the 2 has gone.[/COLOR]

If I replace the ‘id’ in the original query with a ‘*’ I get every field twice for only one row. The output is
[COLOR=darkred]0 - 1[/COLOR]
[COLOR=darkred]id - 1[/COLOR]
[COLOR=darkred]1 - bob[/COLOR]
[COLOR=darkred]name - bob[/COLOR]
[COLOR=darkred]2 - 36[/COLOR]
[COLOR=darkred]age - 36[/COLOR] etc etc.

What am I doing wrong? I have been at this all night. It should be really simple and I am sure it is something dumb but I am going mad!