Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2003
    Location
    Everett, Washington
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How do I get values from select?

    I need to assign values pulled by a select query to varibles, but the only thing I know how to do with the values I get from a select query is make a table. Below is the code that puts the values I need stored in variables in a table:

    $query = "SELECT title, description, height, width FROM images WHERE filename = '$imagepath'";
    $result = mysql_query($query)
    or die (mysql_error());
    echo "<TABLE BORDER=1>";
    WHILE ($row = mysql_fetch_array($result, MYSQL_ASSOC))
    {
    echo "<tr>";
    WHILE ( list ($key, $value) = each($row) )
    {
    echo "<TD>" . $value . "</TD>";
    }
    echo "</TR>";
    }
    echo "</TABLE>";

    Its designed to call only one row so I just need the four values called in the query to have their own variable, could someone show me how to do this?

  • #2
    New Coder
    Join Date
    Jun 2003
    Location
    Everett, Washington
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nevermind I got it with:

    $query = "SELECT title, description, height, width FROM images WHERE filename = '$imagepath'";
    $result = mysql_query($query)
    or die (mysql_error());
    }
    while ($row = mysql_fetch_assoc($result)) {
    $title = $row['title'];
    $desc = $row['description'];
    $height = $row['height'];
    $width = $row['width'];
    }


  •  

    Posting Permissions

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