471,309 Members | 1,285 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,309 software developers and data experts.

noob question

Okay, I know how to:
- construct a SQL query and get a result set
- loop through the result set and echo the fields I need

But what I really need to do is get a value from a field and put it in a
variable, and I can't seem to get it to work, because then the variable just
holds "resource id#"
So the query I'm using returns only one row, since I'm filering on the
primary key, and I can test for one row returned. If one row is returned,
how do I pull out the value of one field and put it in a variable?

I know this is very basic stuff, but I can't seem to find the answer. Even
just a very simple reply, pointing me in the right direction would be
greatly appreciated.

Thanks!

Ernie
Jan 7 '07 #1
3 1137
On Sun, 7 Jan 2007 09:39:17 -0800, "ernie.bornheimer"
<er**************@gmail.comwrote:
>Okay, I know how to:
- construct a SQL query and get a result set
- loop through the result set and echo the fields I need

But what I really need to do is get a value from a field and put it in a
variable, and I can't seem to get it to work, because then the variable just
holds "resource id#"
So the query I'm using returns only one row, since I'm filering on the
primary key, and I can test for one row returned. If one row is returned,
how do I pull out the value of one field and put it in a variable?
mysql_result or mysql_fetch_array.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jan 7 '07 #2
You can also try... mysql_fetch_assoc - this will give you an array of
the values, where the keys of the array would be associative. For
instance, it'll have for a table that's got the fileds "Name" and
"Surname" the following array:
array {
[Name] =peter
[Surname] =pan
}

Andy Hassall wrote:
On Sun, 7 Jan 2007 09:39:17 -0800, "ernie.bornheimer"
<er**************@gmail.comwrote:
Okay, I know how to:
- construct a SQL query and get a result set
- loop through the result set and echo the fields I need

But what I really need to do is get a value from a field and put it in a
variable, and I can't seem to get it to work, because then the variable just
holds "resource id#"
So the query I'm using returns only one row, since I'm filering on the
primary key, and I can test for one row returned. If one row is returned,
how do I pull out the value of one field and put it in a variable?

mysql_result or mysql_fetch_array.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jan 7 '07 #3
Thank you both, these suggestions were just what I needed.

Ernie

"Sarel" <sa*****@gmail.comwrote in message
news:11**********************@i15g2000cwa.googlegr oups.com...
You can also try... mysql_fetch_assoc - this will give you an array of
the values, where the keys of the array would be associative. For
instance, it'll have for a table that's got the fileds "Name" and
"Surname" the following array:
array {
[Name] =peter
[Surname] =pan
}

Andy Hassall wrote:
>On Sun, 7 Jan 2007 09:39:17 -0800, "ernie.bornheimer"
<er**************@gmail.comwrote:
>Okay, I know how to:
- construct a SQL query and get a result set
- loop through the result set and echo the fields I need

But what I really need to do is get a value from a field and put it in a
variable, and I can't seem to get it to work, because then the variable
just
holds "resource id#"
So the query I'm using returns only one row, since I'm filering on the
primary key, and I can test for one row returned. If one row is
returned,
how do I pull out the value of one field and put it in a variable?

mysql_result or mysql_fetch_array.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

Jan 10 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Dave Williams | last post: by
10 posts views Thread by Matt Hollingsworth | last post: by
3 posts views Thread by We need more power captain | last post: by
8 posts views Thread by Ivan Shevanski | last post: by
2 posts views Thread by Chris Dunaway | last post: by
2 posts views Thread by Dan McCollick | last post: by
reply views Thread by AndyW | last post: by
6 posts views Thread by Lang Murphy | last post: by
reply views Thread by rosydwin | last post: by

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.