...

View Full Version : How do I get values from select?



ensinger
06-26-2003, 10:11 PM
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?

ensinger
06-26-2003, 10:50 PM
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'];
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum