noob question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ernie.bornheimer

    #1

    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


  • Andy Hassall

    #2
    Re: noob question

    On Sun, 7 Jan 2007 09:39:17 -0800, "ernie.bornheim er"
    <ernie.bornheim er@gmail.comwro te:
    >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_arr ay.

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

    Comment

    • Sarel

      #3
      Re: noob question

      You can also try... mysql_fetch_ass oc - 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.bornheim er"
      <ernie.bornheim er@gmail.comwro te:
      >
      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_arr ay.
      >
      --
      Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
      http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

      Comment

      • ernie.bornheimer

        #4
        Re: noob question

        Thank you both, these suggestions were just what I needed.

        Ernie

        "Sarel" <sarel.w@gmail. comwrote in message
        news:1168197662 .488440.142000@ i15g2000cwa.goo glegroups.com.. .
        You can also try... mysql_fetch_ass oc - 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.bornheim er"
        ><ernie.bornhei mer@gmail.comwr ote:
        >>
        >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_arr ay.
        >>
        >--
        >Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
        >http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
        >

        Comment

        Working...