// start a session
session_start();
// setup the db connection
$user="deb12177_user";
$password="tf][HTZ)(vt^L2010";
$database="deb12177_photos";
mysql_connect(localhost, $user, $password);
@mysql_select_db($database) or die ( "Unable to select database");
// get the category data from the db
$query = "SELECT * FROM category WHERE ((id = 34) OR (id = 2) OR (id = 3) OR (id = 4))";
$result = mysql_query($query);
// select 4 random pictures from the favourites to use as thumbnails
$query = "SELECT * FROM picture JOIN pic_cat ON pic_cat.pic_id = picture.id WHERE pic_cat.cat_id=34 ORDER BY RAND() LIMIT 4";
$picresult = mysql_query($query);
// check if we need to keep statistics
$nostats = $_GET['nostats'];
if ($nostats == 2)
{
// administrator mode, we append the parameter setting to all links
$refnostats = "&nostats=2";
}
// we now proceed with printing the page header
?>
>
echo $catrow['name_short']; ?>
(
if ($catrow['id'] == 34)
{
$numpics = mysql_fetch_array(mysql_query("SELECT COUNT(pic_id) FROM pic_cat WHERE cat_id=34"));
}
else
{
$numpics = mysql_fetch_array(mysql_query("SELECT COUNT(id) FROM picture"));
}
echo $numpics[0];
?> Images)
}
echo "
";
echo "
";
}
?>
Guestbook:
// see if there are comments for this page
$commentsresult = mysql_query("SELECT * FROM comments WHERE (pic_id=0 AND spam=0)");
if (mysql_num_rows($commentsresult) > 0)
{
?>
Comments:
while ($commentrow = mysql_fetch_assoc($commentsresult))
{ ?>
echo stripslashes($commentrow['name']);
?>
echo $commentrow['date'];
?>
echo stripslashes($commentrow['comment']); ?>
}
?>
}
else
{
echo "No comments in the guestbook yet :-(
";
}
?>
Leave a message!
include("printcommentform.php");
?>
Total images:
$numpics = mysql_fetch_array(mysql_query("SELECT COUNT(id) FROM picture"));
echo $numpics[0];
?>
| Last update: 07/02/2011 0:05 AM | Programmed in a serendipitous mixture of PHP and Matlab | Design by Chameleon |
if ($nostats == 0)
{ ?>
}
?>
// we are done with the database now
mysql_close();
?>