Firstly, i removed the $id = $_GET['id']; and in the MySQL query i edited "WHERE id = $id" to "ORDER BY id" (there is a column in the database called id)
and the equal to view thing, i tried to remove this function a while to see what happened, i interpreted it to be the exact same function as the empty() strings.
New code:
<?php
include ("config.php");
$max = 8; //amount of articles per page. change to what you want
$p = $_GET['p'];
if(empty($p))
{
$p = 1;
}
$limits = ($p - 1) * $max;
//view the news article!
//if(isset($_GET['kat']))
//{
// Vad är $typ?
$typ = "Program";
// Kollar ifall någon kategori är angiven
if (!empty($typ))
{
// Eller så visas endast de med den anginvna kategorin
$sql = mysql_query("SELECT * FROM Greenbay_guides WHERE typ = '$typ' ORDER BY id");
}
else
{
// Om inte, visa alla
$sql = mysql_query("SELECT * FROM Greenbay_guides ORDER BY id");
}
while($r = mysql_fetch_array($sql))
{
$link = $r['files'];
echo "<div class='guidecontainer' style='margin-bottom:5px;'>";
echo "<div style='float:left;margin-right:10px;'>";
echo "<a href='Guides/$link'><img src='http://www.pcstodet.se/Greenbay/Images/Upload/" . $r['img'] . "' width=\"55px\" height=\"55px\" /></div>";
echo "<div style='float:left;width:550px;margin-top:5px;'><a href=\"Guides/$link\"><p>";
echo "<strong>" . $r['name'] . "</strong></p><p>" . $r['descript'] . "</p></a></div></div>";
}
//}else{
//view all the news articles in rows
if (!empty($typ))
{
// Eller så visas endast de med den anginvna kategorin
$sql = mysql_query("SELECT * FROM Greenbay_guides WHERE typ = ".$typ." LIMIT ".$limits.",$max") or die(mysql_error());
}
else
{
// Om inte, visa alla
$sql = mysql_query("SELECT * FROM Greenbay_guides LIMIT ".$limits.",$max") or die(mysql_error());
}
//the total rows in the table
$totalres = mysql_result(mysql_query("SELECT COUNT(id) AS tot FROM Greenbay_guides"),0);
//the total number of pages (calculated result), math stuff...
$totalpages = ceil($totalres / $max);
while($r = mysql_fetch_array($sql))
{
$link = $r['files'];
echo "<div class='guidecontainer' style='margin-bottom:5px;'>";
echo "<div style='float:left;margin-right:10px;'>";
echo "<a href='Guides/$link'><img src='http://www.pcstodet.se/Greenbay/Images/Upload/" . $r['img'] . "' width=\"55px\" height=\"55px\" /></div>";
echo "<div style='float:left;width:550px;margin-top:5px;'><a href=\"Guides/$link\"><p>";
echo "<strong>" . $r['name'] . "</strong></p><p>" . $r['descript'] . "</p></a></div></div>";
}
echo "<p>Sida: ";
for($i = 1; $i <= $totalpages; $i++){
//this is the pagination link
echo "<a href='archive.php?p=$i'>$i</a> ";
}
echo "Typ: ".$typ."";
echo "</p>";
//}
?>
This returns an mysql_error, which states "Unknown column 'Program' in 'where clause'". There is a column named "typ" in my database and the two articles i have in it has this column set to "Program". This i don't understand, shouldn't "typ = whatever" be column = value in column?
EDIT: It's the second mysql_query that returns the error, look at the link to see how far it gets.. http://www.pcstodet.se/Greenbay/archive.php