I have the following query:
SELECT * FROM purchase WHERE userid='$userid' AND start='0000-00-00 00:00:00'
I have a counter which is reporting 22 items in the returned array. So, I looped them. It reports the same item 22 times.
Here is the code:
$rowpur=mysql_fetch_array($resultpur);
$number=count($rowpur);
echo $number."=number<br>";
echo $userid."=user<br>";
for ($i=0; $i<$number; $i++){
$puruser=$rowpur['userid'];
$purstart=$rowpur['start'];
$purid=$rowpur['purchaseid'];
echo $puruser."=Purusr<br>";
echo $purstart."=purstart<br>";
echo $purid."=purid<br>";
echo "<br>";
}
This is the output:
l=user
**=pw
22=number
11=user
11=Purusr
0000-00-00 00:00:00=purstart
123=purid
11=Purusr
0000-00-00 00:00:00=purstart
123=purid
11=Purusr
0000-00-00 00:00:00=purstart
123=purid
11=Purusr
0000-00-00 00:00:00=purstart
123=purid
11=Purusr
0000-00-00 00:00:00=purstart
123=purid
11=Purusr
0000-00-00 00:00:00=purstart
123=purid
<snip> THere are 22
Two problems:
The purid is a key field and only has one record.
When I run the query thru myAdmin I get 11 records but only one has the purid of 123.
Where have I gone wrong?
Why would the same record be returned 22 times?
OR, Why would the count be off?