Alright, I've been looking up and down this code a couple of times now. And I've read through yor tips several times...But I seem to be stuck a one point:
I've made the menu, but I don't understand how I'm supposed to make the links work...
This is the code so far (bear with me, it's messy cause I've been testing a lot):
I now have a database with 2 tables 'gallery' and 'image' where gallery contains GID (GalleryID) and name, image contains ImID (ImageID), GID, adr (filepath) and alt (alt name).Code:<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache");
header("Pragma: no-cache");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>A PHP-Site</title>
</head>
<body>
<?php
echo "\t<center><h2>This page has a body of pure PHP</h2></center>\n";
mysql_connect('localhost','root')
|| die(mysql_error());
@mysql_select_db(thorbear)
|| die("Unable to select database");
//Skriver ut alt i tabellen
$query = mysql_query('SELECT * FROM gallery');
$num_rows = mysql_num_rows($query);
$i = 0;
if ($num_rows == 0)
{
echo "<b>No galleries in database</b>";
}
else
{
while ($i < $num_rows)
{
$GID = mysql_result($query,$i,"GID");
$name = mysql_result($query,$i,"name");
echo "\n\t\t<a href=\"purePHP.php?\$galleryid=$GID\">$name</a><br />";
$i++;
}//while
}
$query2 = mysql_query("SELECT * FROM image WHERE GID = '$galleryid'");
$num_rows2 = mysql_num_rows($query2);
$i2 = 0;
if ($num_rows2 == 0)
{
echo "<b>No images in selected gallery</b>";
}
else
{
while($i2 < $num_rows2)
{
$ImID = mysql_result($query2,$i2,'ImID');
$alt = mysql_result($query2,$i2,'alt');
$adress = mysql_result($query2,$i2,'adress');
echo "\n\t\t<img src=\"$adress\" alt=\"$alt\">";
$i2++;
} // while
}
mysql_free_result($query);
mysql_free_result($query2);
//Lukker koblingen til databasen
mysql_close();
echo "\n\t\t<p>© Thorbear Incognito</p>\n";
?>
</body>
</html>