aj_nsc
10-21-2006, 10:32 PM
I am a novice in PHP and a complete beginner to MySQL and I have (what I deem to be) a fairly simple question. I am trying to get a single field value out of MySQL...the database structure is below:
Database name = bhwbpast_content
Table name = page_table
Table structure = pageID title contentID
I am trying to get the value for 'title' out of database by referencing pageID, which is the unique value in this database.
When someonw views my site at index.php, the page uses a php script to determine the id ($id) of the script ($id=0 when page equals index.php) and I want to get the title value when the pageID = 0. I call a PHP function that connects to the database (no problems there) and runs the following function:
function getHeaderImage($id) {
$query = "SELECT title FROM page_table WHERE pageID='$id'";
$image = mysql_query($query);
echo "<img src=\"images/header/".$image."\.gif" alt=\"\" />";
}
Where $id is the variable (successfully) passed to the function. However, it echo's "Resource id #6" when I view the page source. Am I missing a step between the $image variable and the echo statement which will turn $image into the actual value???
Database name = bhwbpast_content
Table name = page_table
Table structure = pageID title contentID
I am trying to get the value for 'title' out of database by referencing pageID, which is the unique value in this database.
When someonw views my site at index.php, the page uses a php script to determine the id ($id) of the script ($id=0 when page equals index.php) and I want to get the title value when the pageID = 0. I call a PHP function that connects to the database (no problems there) and runs the following function:
function getHeaderImage($id) {
$query = "SELECT title FROM page_table WHERE pageID='$id'";
$image = mysql_query($query);
echo "<img src=\"images/header/".$image."\.gif" alt=\"\" />";
}
Where $id is the variable (successfully) passed to the function. However, it echo's "Resource id #6" when I view the page source. Am I missing a step between the $image variable and the echo statement which will turn $image into the actual value???