www.webdeveloper.com
Results 1 to 2 of 2

Thread: Getting data from a database...

  1. #1
    Join Date
    Dec 2002
    Location
    Australia
    Posts
    32

    Getting data from a database...

    I am trying to get data back out out of a database in the following way....

    $sql = "SELECT * FROM tablename WHERE id='$id'";
    $result = mysql_query($sql);
    $something = mysql_result($result,"field-name-i-want");
    echo "$something";

    But for some reason it only ever returns the first field in the table as opposed to the "field-name-i-want"

    WHY????

    The "printf" thing works fine, but I want it in a variable!!
    Brendan Nolan
    unsharpmask.com

  2. #2
    Join Date
    Dec 2002
    Location
    Australia
    Posts
    32
    Okay I have it... but just so that if anyone else finds themselves in the same position then here it is...

    $myrow = mysql_fetch_array($result);
    $something = mysql_result("thing-i-want");
    Brendan Nolan
    unsharpmask.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles