I'm sorry to keep beating this into the gound, but, my dilemma is that I'm trying to use the following script (results.php) with "showimage.php". I'll try to be more specific. The results script outputs the name and description of the part along with a button for more info and a button for a photo if the part has an image in the database. This script is working fine as far as outputting the part description and the buttons. But I still can't get the photo button to work with "showimage.php".
I was told to use this line:
<img src="showimage.php?id=$id width=600 height = 400">
But I've tried this (using A HREF), to output a button if there is an image to accompany the part, because I want to use the button to to display the image on its own page:
<?php if ($image != "") { ?>
<TD><A HREF="showimage.php?ID=$id width = 640 height = 480"><IMG SRC="b-photo.gif"></A></TD>
</TR>
<p>
<?
Here is the whole "results.php:
<!-- results.php -->
<html>
<head>
<title> Skymusik Search Results </title>
</head>
<body BGCOLOR="#000000" >
<CENTER><IMG SRC="skygrasm1.jpg"></CENTER><BR>
<h2><Font Color="#C6EFF7">Skymusik Search Results</Font> </h2>
<br><a href="index.php"><Font Color="Red">New Search</Font></a>
<?php
$dbcnx = mysql_connect('localhost', 'root','thegman');
mysql_select_db('skymusik_com');
// The basic SELECT statement
$select = "SELECT DISTINCT ID, name, filedata, mimetype";
$from = " FROM parts";
$where = " WHERE ID > 0";
// As the categories associated with a particular part are stored in the partLookup
// table, we need to add this table to the query to create a join. To do this, we simply
// tack the name of the table onto the end of the $from variable
if ($cid != "") { // A category is selected
// to complete the join we must also specify that the ID column (in the jokes table)
$from .= ", partlookup";
// must match the JID column (in JokeLookup), so we add this condition to the $where variable.
// finally we require the CID column (in JokeLookup) to match the category ID selected in the form $cid)
$where .= " AND ID=PID AND CID=$cid";
}
$parts = mysql_query($select . $from . $where);
if (!$parts) {
echo("<p>Error retrieving parts from database!<br />".
"Error: " . mysql_error() . "</p>");
exit();
}
$num_results = mysql_num_rows($parts);
?>
<p>
<Font Color="#C6EFF7"> <?php echo "Number of parts found: ".$num_results."</p>";
?></Font>
<?php
while ($row = mysql_fetch_array($parts)) {
$name = htmlspecialchars($row["name"]);
$image = ($row["filedata"]);
echo "<strong>";
?>
<HR Size="2" WIDTH="700" ALIGN="center">
<Font Color="#C6EFF7"> <?php echo htmlspecialchars(stripslashes("$name\n"));
?></Font>
<?php echo "</strong>";
?>
<Table CELLSPACING=5 CELLPADDING=5>
<TR>
<TD><A HREF="request.php"><IMG SRC="b-rinfo.gif"></A></TD>
<?php if ($image != "") { ?>
<TD><A HREF="showimage.php?ID=$id width = 640 height = 480"><IMG SRC="b-photo.gif"></A></TD>
</TR>
<p>
<?
}
?>
</TABLE>
<HR Size="2" WIDTH="700" ALIGN="center">
<?php
echo "</p>";
}
?>
</table>
</body>
</html>
Does this give you any more detail in what I'm trying to do?
Thanks!