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 2 1581
KDawg44 wrote:
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 http://us3.php.net/manual/en/functio...etch-array.php
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
On Feb 9, 10:21 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
KDawg44 wrote:
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
http://us3.php.net/manual/en/functio...etch-array.php
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attgl obal.net
=============== ===
By strange behavior i meant normal behavior.... thanks! I use a text
as a reference (little older, maybe that's why) and it did not say
anything about this.
Thanks again Jerry! You are the king. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: asra_baig |
last post by:
I have a MySQL database and I'm able to access it correctly. I am also
able to execute select, update and insert queries, however I am getting
warnings saying:
"supplied argument is not a valid MySQL result resource" and the result
set returned is empty (for queries other than select).
Strangely, my die function includes the query but the...
|
by: Good Man |
last post by:
Hey there
I have a dumb question....
Let's say i have a database full of 4000 people.... I select everything
from the database by:
$result = mysql_query("SELECT * FROM People");
|
by: Alexander Inochkin |
last post by:
Hi!
I found same strange behavior of ASP.NET. It is possible this is the bug.
Follow the steps:
|
by: ivb |
last post by:
Hi all,
I am using DB2 8.1.11.1 on NT with ASP.NET 1.1
When application make connection to database (via ADO.NET), it set
"Connection timeout" parameter to 30 seconds.
After, when my webpage requests database, and query execution time
exceeds 30 seconds, the following error reported:
===
|
by: Joseph Geretz |
last post by:
Writing an Outlook AddIn with C#. For the user interface within Outlook I'm
adding matching pairs of Toolbar buttons and Menu items. All of the buttons
and menu items are wired up to send events to the same method (aka
delegate?). I use the Tag property within this method to determine what user
action is taking place. Very simple:
When...
| |
by: Petr Vileta |
last post by:
Hi, I'm new here and excuse me if this question was be here earlier.
I have a simple code
<html><body>
<?php
<?php
$link = mysql_connect("localhost", "user", "password")
or die("Grr: " . mysql_error());
mysql_select_db("my_dbf") or die("Grr");
|
by: Dave |
last post by:
Hi guys,
I have just set up a duplicate server running:
apache 2.54, mysql 5.04 and php 5.04
This is the same setup as as the server we are using now, apart from
the hardware inside. I have copied across the database and website,
with exact same permissions as the first server.
The problem is that part of the php code is executing but...
|
by: Marcel Molenaar |
last post by:
Anyone ever experienced this problem.
When i pass a mysql result to the constructor of a class and use that
resultset inside that class the original resultset outside the class gets
affected too. That is not right i think because my result inside my class is
private. Is this a bug? Can someone look at my code below please:
<?php
...
|
by: Marcel Molenaar |
last post by:
Anyone ever experienced this problem.
When i pass a mysql result to the constructor of a class and use that
resultset inside that class the original resultset outside the class gets
affected too. That is not right i think because my result inside my class is
private. Is this a bug? Can someone look at my code below please:
<?php
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |