i have been trying to make a tag system for my page, and sofar it has been working with a few kinks. i have also been trying to make it page based 30 images per page and so on. I managed to get it to work but the the images shown has now become messed up, and when you press "next page" on the bottom everyting becomes messed up and i dont know how to solve it and hope that someone can help me, the code in the notpaste link bellow and the example link is showing the problem for one of my tags on the site.
Code: http://nopaste.php-quake.net/9687 (Everah | Code snagged from link and posted below)
Everah | It's ok, you can post code here. We don't mind:
Code: Select all
<?
include "includes/inc.php";
require_once("header.php");
$template->set_filenames(array(
'body' => 'tags.html')
);
?>
<?php
$con = mysql_connect("localhost","asd","das") OR die('Could not connect: ' . mysql_error());
mysql_select_db("asd", $con);
//This checks to see if there is a page number. If not, it will set it to page 1
if (!(isset($pagenum)))
{
$pagenum = 1;
}
//Edit $result to be your query
$result = mysql_query("
SELECT *
FROM `images`
WHERE `tags`
LIKE '%" . mysql_real_escape_string($_GET['tag']) . "%'
ORDER BY views
$max
")
OR die(mysql_error());
$rows = mysql_num_rows($result);
//This is the number of results displayed per page
$page_rows = 30;
$last = ceil($rows/$page_rows);
pages
if ($pagenum < 1)
{
$pagenum = 1;
}
elseif ($pagenum > $last)
{
$pagenum = $last;
}
$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;
while($row = mysql_fetch_array($result))
{
echo '<div style="float:left;width:25%"><a href="http://mydomain.net/show.php/' .$row['id'].'_' .$row['name'].'"><img src="http://www.mydomain.net/out.php/t' .$row['id'].'_' .$row['name'].'"></a></div>';
echo "<br>\n";
}
?>
<div style="clear:both"></div>
<?
// This shows the user what page they are on, and the total number of pages
echo " --Page $pagenum of $last-- <p>";
if ($pagenum == 1)
{
}
else
{
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> ";
echo " ";
$previous = $pagenum-1;
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> ";
}
//just a spacer
echo " ---- ";
if ($pagenum == $last)
{
}
else {
$next = $pagenum+1;
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> ";
echo " ";
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> ";
}
?>
<?
include "footer.php";
?>