query.php <?php
session_start(); ?> <html> <?php
// connect to database // the database has fields: thumbs, reference,
and description
$db = mysql_connect("host","name","password");
mysql_select_db("database",$db) or die ('Unable to connect to
database'); $q="SELECT * FROM table"; $result = mysql_query(
$q, $db ) or die(" - Failed More Information:<br><pre>$q</pre><br>Error:
" . mysql_error()); //if result carry on $num_rows = mysql_num_rows($result);
if ($myrow = mysql_fetch_array($result)) { //specify thumbnail folder
$tn='<img src=http://your_web_site/thumbs/'; // specify target for
link // in this case it's to retrieve more info based on the thumbnail
$web='http://your_web_site/detail/index.php?name='; echo "<br>Listed
below<BR><br>"; echo "<table border=1>\n";
echo "<tr><td><b>Reference:</b></td><td>Text:</td><td>Thumb:</td></tr>\n";
do { // 3 columns in this example printf("<tr><td>%s</td><td>%s</td><td><a
href=$web%s>$tn%s.jpg></a></td></tr>\n",
//display reference, description and thumb database info in this example //
the last 2 combine into a link with a reference to carry // just one column,
thumb alone, would be // printf("<tr><td><a href=$web%s>$tn%s.jpg></a></td></tr>\n",
// $myrow["reference"], $myrow["thumb"]);
$myrow["reference"], $myrow["description"],$myrow["reference"],
$myrow["thumb"]); } while ($myrow = mysql_fetch_array($result));
echo "</table>\n"; } else { echo "<font face=verdana,arial,helvetica
size=2 color=blue>Sorry -- the records appear to be unavailable</font>:<br>Has
there been a typo? Try again?"; } mysql_free_result($result);
mysql_close($db); ?></html>
/detail/index.php <?PHP session_start(); ?> <html> <?php $ref="$name"; if
(empty($ref)) { echo "Oooops, lost the reference"; // and exit exit; } //do
a database query on that reference $query
= "SELECT * FROM db_table WHERE reference='$ref'";
?> </html> |