Jump to content

need help with tags codes


izlik

Recommended Posts

Hey there.

 

im a beginner at php and started trying to make a tag script, and i got told i almost got it to work.

 

if you go to http://filefrog.net/new.php?&s=300 and press the tag "games" (has enouff pictures to show the problem) and then go to the bottom of the page and press "next" the codes switch pages but shows the same images on both pages, why?

 

<?
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;

//This tells us the page number of our last page
$last = ceil($rows/$page_rows);

//this makes sure the page number isn't below one, or more than our maximum pages
if ($pagenum < 1)
{
$pagenum = 1;
}
elseif ($pagenum > $last)
{
$pagenum = $last;
}

while($row = mysql_fetch_array($result))
{
   
echo '<div style="float:left;width:25%"><a href="http://filefrog.net/show.php/' .$row['id'].'_' .$row['name'].'"><img src="http://www.filefrog.net/out.php/t' .$row['id'].'_' .$row['name'].'"></a></div>';
    echo "<br>\n";

}   
$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;
?>
<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&tag={$_GET['tag']}'> <<-First</a> ";
echo " ";
$previous = $pagenum-1;
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous&tag={$_GET['tag']}'> <-Previous</a> ";
}

//just a spacer
echo " ---- ";

if ($pagenum == $last)
{
}
else {
$next = $pagenum+1;
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next&tag={$_GET['tag']}'>Next -></a> ";
echo " ";
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last&tag={$_GET['tag']}'>Last ->></a> ";
}
?>
<?
include "footer.php";
?>

Link to comment
https://forums.phpfreaks.com/topic/78275-need-help-with-tags-codes/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.