473,587 Members | 2,229 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

printing out array keys

i'm trying to find a simple way of printing out the keys in an array
generated by mysql_fetch_arr ay which returns a single row.

i.e.

while ($row=mysql_fet ch_array($resul t) )
{

print out the $row keys and values

}

is this possible?

Jul 17 '05 #1
4 13710
kaptain kernel (63.885% quality rating):

print out the $row keys and values

is this possible?


print_r ?

/joe
--
Jordan kisses a muff from git.talk.flame in the Earl. Sixth Street is
plus-cute in Smyrna!! In El Myr, Taco Bell is elementary. Alpharetta is
swell.
Jul 17 '05 #2
kaptain kernel wrote:
i'm trying to find a simple way of printing out the keys in an array
generated by mysql_fetch_arr ay which returns a single row.

i.e.

while ($row=mysql_fet ch_array($resul t) )
{

### print out the $row keys and values
foreach ($row as $k=>$v) {
echo "row[$k] = $v<br/>\n";
}

}

is this possible?


With mysql_fetch_arr ay() you'll get both numeric and column names
indices. I only use mysql_fetch_row () for numeric indices and
mysql_fetch_ass oc() for column names indices.
HTH

--
..sig
Jul 17 '05 #3
kaptain kernel wrote:
i'm trying to find a simple way of printing out the keys in an array
generated by mysql_fetch_arr ay which returns a single row.


$query = "SELECT * FROM table WHERE `key`='value' LIMIT 1";
$result = mysql_query($qu ery);
$row = mysql_fetch_arr ay($result,MYSQ L_ASSOC);

foreach($row as $key => $value) {
echo "key: $key , value: $value <br>";
}

HTH

--
Suni
Jul 17 '05 #4
thanks - the foreach key=>value construct is exactly what i'm looking
for.....

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1280
by: waisty vb.net rookie | last post by:
How do i use cursor keys or other non printing keys like alt and shift to raise an event. If it's possible, how do i use the keypress event to do it -- Thanks for reading
7
3199
by: Magnus Warker | last post by:
Hi, I want to traverse an (associative) array, starting from its current position, until a certain element is reached. Then, in certain cases, I want to be able to reset the current position of the array to the one that we had before touching the array. I. e., i need something like funcctions getpos and setpos: ----------
4
9218
by: Arif | last post by:
I C# code prints very slow as compared to a third party barcode printing software. That software prints approximately 10 labels in 2 seconds while my C# code prints 10 labels in 5 to 6 seconds. And this differences increases with the increase number of labels. The code is as follwods: Here rdr = OleDbDataReader Font is Times New Roman, 12pt
7
2149
by: pauld | last post by:
Ive got a series of 2 dimensional associative arrays while(list($key, $val) = each ($results)) { {foreach($val as $i=>$v) print "$i = $v"; } } but i want to define the order that the various $i's are printed in
6
2234
by: routeslip | last post by:
I'm refering to an entry in an array by it's string key, as in foo. Is there a way to get the numeric index of that array without iterating through the entire array? What I need to do is find the "next" or "previous" entry in the array, but the keys are strings, instead of numerical indeces. thanks for your help.
4
2197
by: Markus Ernst | last post by:
Hi While looping through an array I extract all keys on the fly, as in this example: $data = array( array('name' ='Helen', 'age' ='40'), array('name' ='Mark', 'email' ='mark@xyz.com', 'age' ='90'), ); $keys = array();
3
1551
by: Mike P | last post by:
I have an array of invoice keys that I need to loop through, display in a window on screen, then auto print, before looping to the next one, again displaying on screen, and then auto printing. I have my array sorted, and I am planning on building up the HTML invoice using a StringBuilder and then displaying it via a div InnerHtml. But how...
2
5806
by: Sjoerd | last post by:
On Mon, 08 Sep 2008 00:11:38 -0700, mouac01@yahoo.com wrote: Loop through the array and make an array of all keys. Then loop through the array again and add the missing keys.
6
5496
by: tedpottel | last post by:
Help How can I remove an item from an array, Example Array=3, array=6 array=7 array=9 Is there a way to remove a item, say index 1, so the array would now be Array=3 array=7 array=9 ?????
0
8205
Oralloy
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. ...
0
8339
jinu1996
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...
1
7967
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...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6619
agi2029
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...
1
5712
isladogs
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...
0
3872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2347
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
0
1185
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.