Hi,
I have the following code:
$resultSet = mysql_query($sq lString);
$numResults = mysql_num_rows( $resultSet);
echo "Num Results = " . $numResults . "<br/>";
for ($i = 0; $i < $numResults; $i++) {
$row = mysql_fetch_arr ay($resultSet);
echo "i = " . $i . "<br/>";
foreach ($row as $key=>$r) {
echo $key . " = " . $r . "<br/>";
}
}
When I run the query at the MySQL Command prompt, I get exactly one
record, which is correct. However, when I echo the key value pairs,
it is printing the values twice, once with a numeric key (index) and
then again with the proper key name. For example, here is the first
bit of the output:
i = 0
0 = 2
ApptID = 2
1 = 1
CustID = 1
2 = 1
DogID = 1
3 = 2
4 = 12:00:00
ApptTime = 12:00:00
5 = 03:00:00
PickupTime = 03:00:00
6 = 1
7 = Mac
Name = Mac
8 = 1
9 = Kevin and Erika
FName = Kevin and Erika
10 = Holleran
LName = Holleran
I just want the key=>pairs! How do I get rid of the index thing?!
Thanks for any help.
Kevin
I have the following code:
$resultSet = mysql_query($sq lString);
$numResults = mysql_num_rows( $resultSet);
echo "Num Results = " . $numResults . "<br/>";
for ($i = 0; $i < $numResults; $i++) {
$row = mysql_fetch_arr ay($resultSet);
echo "i = " . $i . "<br/>";
foreach ($row as $key=>$r) {
echo $key . " = " . $r . "<br/>";
}
}
When I run the query at the MySQL Command prompt, I get exactly one
record, which is correct. However, when I echo the key value pairs,
it is printing the values twice, once with a numeric key (index) and
then again with the proper key name. For example, here is the first
bit of the output:
i = 0
0 = 2
ApptID = 2
1 = 1
CustID = 1
2 = 1
DogID = 1
3 = 2
4 = 12:00:00
ApptTime = 12:00:00
5 = 03:00:00
PickupTime = 03:00:00
6 = 1
7 = Mac
Name = Mac
8 = 1
9 = Kevin and Erika
FName = Kevin and Erika
10 = Holleran
LName = Holleran
I just want the key=>pairs! How do I get rid of the index thing?!
Thanks for any help.
Kevin
Comment