i've moded something to a kind of bookmarks page, but it's something that instead of user see his marks, he can see marks from all other users, and his marks are visible to all others.
so, when i visit this page, it seeks for the id of the user i want to check his marks.
so far so good.
to order the page, i put on it the "ABC....Z All" list, but when i click on some letter, nothing happens, page keeps showing the complete marks list from user.
so, what should i do to correct this?
(thanks in advance)
you should look to this part:
Quote:
$l = chr($i);
$L = chr($i - 32);
$lol = "?id=$id";
if ($l == $letter)
print(" <font size=4><b>$L</b></font>\n");
else
print(" <a href=". $lol ."?letter=$l
|
PHP Code:
<?
require "include/bittorrent.php";
dbconn();
//loggedinorreturn();
stdhead("Lista");
$id = (int)$_GET["id"];
$page = $_GET['page'];
$perpage = 1000;
$resc = mysql_query("SELECT COUNT(*) FROM bookmarks WHERE bookmarks.userid = $id AND (bookmarks.local = 'Disco' OR bookmarks.local = 'CD/DVD')") or die(mysql_error());
$rowc = mysql_fetch_array($resc,MYSQL_NUM);
$count = $rowc[0];
$order = "torrents.nameorig ASC";
if ($count)
{
//list($pagertop, $pagerbottom, $limit) = pager($bookmarksperpage, $count, "minhalistapublica.php?id=$id?" . $addparam);
$res = mysql_query("SELECT torrents.id, torrents.ano, torrents.epsl, torrents.epst, torrents.status, torrents.comments, torrents.numfiles, torrents.poster, torrents.miniposter, torrents.nameorig, torrents.name, torrents.size, torrents.category, torrents.filename, torrents.added, torrents.seeders, torrents.leechers, torrents.owner, torrents.times_completed AS complete, bookmarks.id AS bid, bookmarks.torrentid, bookmarks.userid, bookmarks.local, bookmarks.visto FROM bookmarks,torrents WHERE bookmarks.userid = '$id' AND torrents.id = bookmarks.torrentid AND (bookmarks.local = 'Disco' OR bookmarks.local = 'CD/DVD') ORDER BY $order $limit") or sqlerr();
if (mysql_num_rows($res) > 0)
{
$pages = floor($arr[0] / $perpage);
if ($pages * $perpage < $arr[0])
++$pages;
if ($page < 1)
$page = 1;
else
if ($page > $pages)
$page = $pages;
for ($i = 1; $i <= $pages; ++$i)
if ($i == $page)
$pagemenu .= "<b>$i</b>\n";
else
$pagemenu .= "<a href=?$q&page=$i><b>$i</b></a>\n";
if ($page == 1)
$browsemenu .= "<b><< Anterior</b>";
else
$browsemenu .= "<a href=?$q&page=" . ($page - 1) . "><b><< Anterior</b></a>";
$browsemenu .= " ";
if ($page == $pages)
$browsemenu .= "<b>Seguinte >></b>";
else
$browsemenu .= "<a href=?$q&page=" . ($page + 1) . "><b>Seguinte >></b></a>";
$offset = ($page * $perpage) - $perpage;
$torrents = "<table class=main border=1 cellspacing=0 cellpadding=6 align=center>\n" .
"
<td class=colhead align=center>+Info</td>
<td class=colhead align=center>Anime</td>
<td class=colhead align=center><img src=pic/buttons/revanidb_mylist.gif> <img src=pic/buttons/seen1.gif></td>
<td class=colhead align=center>Tipo</td>
<td class=colhead align=center>Ano</td>
<td class=colhead align=center>Eps.</td>
<td class=colhead align=center>Estado</td>
<td class=colhead align=center>Ficheiros</td>
<td class=colhead align=center>Fansub</td>
</tr>";
while ($a = mysql_fetch_array($res))
{
//$r1 = mysql_query("SELECT id, username FROM users WHERE id=$a[owner]") or sqlerr(__FILE__, __LINE__);
//$a1 = mysql_fetch_assoc($r1);
//$owner = "<a href=userdetails.php?id=$a1[id]><b>$a1[username]</b></a>";
$r2 = mysql_query("SELECT name, image FROM categories WHERE id=$a[category]") or sqlerr(__FILE__, __LINE__);
$a2 = mysql_fetch_assoc($r2);
$cat = "<img src=\"pic/$a2[image]\" height='24' alt=\"$a2[name]\">";
$ishentai = ($a2["name"]=="Hentai" ? " <font color=red>(+18)</font> <img src='pic/buttons/uncensored.gif' />" : "");
$res2 = mysql_query("SELECT fansubbers.name as f_name, fansubbers.tag AS f_tag, fansubbers.id AS f_id FROM fansubbers
LEFT JOIN torrents ON torrents.fansubber = fansubbers.id WHERE torrents.id =" . $a["id"] . "")
or sqlerr();
$row2 = mysql_fetch_assoc($res2);
$res3 = mysql_query("SELECT estado.image AS est_image, estado.name AS est_name FROM estado LEFT JOIN torrents ON torrents.status = estado.id WHERE torrents.id = $id")
or sqlerr();
$row3 = mysql_fetch_assoc($res3);
if ($a[status] == 1)
$est_proj = ("<img title='Projecto concluído' src=pic/concluido.gif>\n");
elseif ($a[status] == 2)
$est_proj = ("<img title='Projecto em andamento' src=pic/em_andamento.gif>\n");
elseif ($a[status] == 3)
$est_proj = ("<img title='Projecto parado' src=pic/parado.gif>\n");
elseif ($a[status] == 4)
$est_proj = ("<img title='Projecto cancelado' src=pic/warned2.gif>\n");
elseif ($a[status] == 5)
$est_proj = ("<img title='Projecto terminado' src=pic/terminado.gif>\n");
elseif ($a[status] == 6)
$est_proj = ("<img title='Especiais apenas' src=pic/starb.gif>\n");
elseif ($a[status] == 7)
$est_proj = ("<img title='Projecto com estado desconhecido' src=pic/desconhecido.gif>\n");
elseif ($a[status] == 8)
$est_proj = ("<img title=src=pic/+.gif>\n");
else
$est_proj = ("$est_proj\n");
if (($a["name"]) == ($a["nameorig"]))
$dispname = htmlspecialchars($a["nameorig"]);
else
$dispname = htmlspecialchars($a["nameorig"]) ." <br> ". htmlspecialchars($a["name"]);
$data = mysql_query("SELECT size * times_completed AS data FROM torrents WHERE id = '$a[id]'") or sqlerr(__FILE__, __LINE__);
$b = mysql_fetch_assoc($data);
$data = mksize($b["data"]) . "";
$resbook = mysql_query("SELECT bookmarks.id, bookmarks.torrentid, bookmarks.userid, bookmarks.local, bookmarks.visto FROM bookmarks LEFT JOIN torrents ON bookmarks.torrentid = torrents.id WHERE bookmarks.userid = $id AND torrents.id = $a[id] AND bookmarks.id = $a[bid]") or sqlerr();
$rowbook = mysql_fetch_assoc($resbook);
{
{
if ($rowbook["local"] =="--")
$marcalocal = ("");
elseif ($rowbook["local"] =="Disco")
$marcalocal = ("<img src=pic/buttons/state_onhdd.gif border=0 title='Projecto " .$a["nameorig"]. " guardado em Disco'>\n");
elseif ($rowbook["local"] =="CD/DVD")
$marcalocal = ("<img src=pic/buttons/state_oncd.gif border=0 title='Projecto " .$a["nameorig"]. " guardado em CD/DVD'>\n");
else
$marcalocal = ("\n");
}
{
if ($rowbook["visto"] =="--")
$marcavisto = ("");
elseif ($rowbook["visto"] =="completo")
$marcavisto = ("<img src=pic/buttons/seen.gif border=0 title='Projecto " .$a["nameorig"]. " visto na totalidade'>\n");
elseif ($rowbook["visto"] =="parte")
$marcavisto = ("<img src=pic/buttons/seeing.gif border=0 title='Projecto " .$a["nameorig"]. " visto em parte'>\n");
elseif ($rowbook["visto"] =="nunca")
$marcavisto = ("<img src=pic/buttons/seen_no.gif border=0 title='Projecto " .$a["nameorig"]. " nunca visto'>\n");
else
$marcavisto = ("\n");
}
}
//if (($CURUSER[id] == $a[userid]) || (get_user_class() >= UC_MODERATOR) || ($CURUSER[id] == $a[bookmarks]))
//$torrents .= "<tr class=tableb><td style='padding: 3px' align=center><a href=delmark.php?id=$a[bid]><img src=pic/delbookmark.gif border=0 title='Remover dos marcados'></a><br><br><a class=\"index\" href=\"download.php/$a[id]/" . rawurlencode($a["filename"]) . "\"><img src=pic/download.gif border=0 alt='DOWNLOAD $a[name]'></a></td><td style='padding: 0px'>$cat</td><td><a href=details.php?id=" . $a["id"] . "&hit=1><b>" . htmlspecialchars($a["name"]) . "</b></a></td>" .
$torrents .= "<tr class=tableb>
<td align=center><a class=altlink href=details.php?id=" . $a["id"] . "&hit=1><img border='0' title='Ver detalhes do projecto: '". $a["nameorig"] . "'' src=pic/buttons/m_info.gif></a></td>
<td align=center> <a class=altlink href=details.php?id=" . $a["id"] . "&hit=1><b><font color=black>$dispname</font></b></a> $ishentai </td>
<td align=center>$marcalocal $marcavisto</td>
<td align=center>$cat</td>
<td align=center><b>" . $a["ano"] . "</b></td>
<td align=center><b>" . $a["epsl"] . " / " . $a["epst"] . "</b></td>
<td align=center>$est_proj</td>
<td align=center><b><a href=\"files.php?id=$a[id]&hit=1&filelist=1\">" . $a["numfiles"] . "</a> / " . str_replace(" ", " ", mksize($a["size"])) . "</b></td>
<td align=center><a href=\"fansubbersdetails.php?id=". $row2["f_id"] ."\" class=altlink><b><font color=black>[" . $row2["f_tag"] . "]</font></b></a></td>
</tr>\n";
}
$torrents .= "</table>";
}
}
$ret1 = mysql_query("SELECT username FROM users WHERE id=$id") or sqlerr(__FILE__, __LINE__);
$arr1 = mysql_fetch_assoc($ret1);
$user = "<b>$arr1[username]</b>";
print("<table width=690 border=0><h1><b>A lista do utilizador: $user</b></h1></table>\n");
if (!$torrents)
print("<table align=center cellpadding=5><td align=center><b>empty</b><br></td></table>\n");
else if ($count) {
$letter = trim($_GET["letter"]);
if (strlen($letter) > 1)
die;
if ($letter == "" || strpos("abcdefghijklmnopqrstuvwxyz", $letter) === false)
$letter = "";
$query = "nameorig LIKE '$letter%'";
$q = "letter=$letter";
for ($i = 97; $i < 123; ++$i)
{
$l = chr($i);
$L = chr($i - 32);
$lol = "?id=$id";
if ($l == $letter)
print(" <font size=4><b>$L</b></font>\n");
else
print(" <a href=". $lol ."?letter=$l class=altlink><font color=#004E98 size=2><b>$L</b></font></a>\n");
}
if ($letter == "" || strpos("abcdefghijklmnopqrstuvwxyz", $letter) === false)
print(" <font size=4><b>Todas</b></font>\n");
else
print(" <a href=minhalistapublica2.php?id=$id class=altlink><font color=#004E98 size=2><b>Todas</b></font></a>\n");
print("</p>\n");
print("$torrents\n");
if ($letter == "" || strpos("abcdefghijklmnopqrstuvwxyz", $letter) === false)
print("<p align=center><a href=#top class=altlink>Top</a></p>");
}
print("</table>\n");
stdfoot();
?>
you can check the page if you like, here:
http://db.revanime.net/minhalistapublica2.php?id=2
Bump: I changed this part
PHP Code:
$l = chr($i);
$L = chr($i - 32);
$lol = "?id=$id";
if ($l == $letter)
print(" <font size=4><b>$L</b></font>\n");
else
print(" <a href=". $lol ."?letter=$l
to
PHP Code:
$l = chr($i);
$L = chr($i - 32);
if ($l == $letter)
print(" <font size=4><b>$L</b></font>\n");
else
print(" <a href=?id=$id&letter=$l
Now, when i click on some letter at the list, it changes the letter but bellow on the table, the result is the same as if it was on "all letters"
Bump: Don't bother with this.
The problem was in the main query but I already solved it.
Everything's working good now.
Here's the final file
[HIDE]
PHP Code:
<?
require "include/bittorrent.php";
$letter = trim($_GET["letter"]);
if (strlen($letter) > 1)
die;
if ($letter == "" || strpos("abcdefghijklmnopqrstuvwxyz", $letter) === false){
$query = "";
} else {
$query = "AND torrents.nameorig LIKE '$letter%'";
}
$q = "letter=$letter";
stdhead("Lista de anime");
$id = (int)$_GET["id"];
$ret1 = mysql_query("SELECT username FROM users WHERE id=$id") or sqlerr(__FILE__, __LINE__);
$arr1 = mysql_fetch_assoc($ret1);
$user = "<b>$arr1[username]</b>";
print("<table width=690 border=0><h1><b>A lista de anime do utilizador: $user</b></h1></table>\n");
for ($i = 97; $i < 123; ++$i)
{
$l = chr($i);
$L = chr($i - 32);
if ($l == $letter)
print(" <font size=4><b>$L</b></font>\n");
else
print(" <a href=?id=$id&letter=$l class=altlink><font color=#004E98 size=2><b>$L</b></font></a>\n");
}
if ($letter == "" || strpos("abcdefghijklmnopqrstuvwxyz", $letter) === false)
print(" <font size=4><b>Todos</b></font>\n");
else
print(" <a href=minhalistapublica.php?id=$id class=altlink><font color=#004E98 size=2><b>Todos</b></font></a>\n");
print("</p>\n");
$id = (int)$_GET["id"];
$resc = mysql_query("SELECT COUNT(*) FROM bookmarks WHERE bookmarks.userid = $id AND (bookmarks.local = 'Disco' OR bookmarks.local = 'CD/DVD')") or die(mysql_error());
$rowc = mysql_fetch_array($resc,MYSQL_NUM);
$count = $rowc[0];
$order = "torrents.nameorig ASC";
if ($count)
{
$res = mysql_query("SELECT torrents.id, torrents.ano, torrents.epsl, torrents.epst, torrents.status, torrents.comments, torrents.numfiles,
torrents.poster, torrents.miniposter, torrents.nameorig, torrents.name, torrents.size, torrents.category, torrents.filename, torrents.added,
torrents.seeders, torrents.leechers, torrents.owner, bookmarks.id AS bid, bookmarks.torrentid, bookmarks.userid, bookmarks.local,
bookmarks.visto FROM bookmarks,torrents WHERE bookmarks.userid = '$id' AND
torrents.id = bookmarks.torrentid AND (bookmarks.local = 'Disco' OR bookmarks.local = 'CD/DVD') " . $query . " ORDER BY $order $limit") or sqlerr();
if (mysql_num_rows($res) > 0)
{
$torrents = "<table class=main border=1 cellspacing=0 cellpadding=6 align=center>\n" .
"<td class=colhead align=center>+Info</td>
<td class=colhead align=center>Anime</td>
<td class=colhead align=center><img src=pic/buttons/revanidb_mylist.gif> <img src=pic/buttons/seen1.gif></td>
<td class=colhead align=center>Tipo</td>
<td class=colhead align=center>Ano</td>
<td class=colhead align=center>Eps.</td>
<td class=colhead align=center>Estado</td>
<td class=colhead align=center>Ficheiros</td>
<td class=colhead align=center>Fansub</td>
</tr>";
while ($a = mysql_fetch_array($res))
{
$r2 = mysql_query("SELECT name, image FROM categories WHERE id=$a[category]") or sqlerr(__FILE__, __LINE__);
$a2 = mysql_fetch_assoc($r2);
$cat = "<img src=\"pic/$a2[image]\" height='24' alt=\"$a2[name]\">";
$ishentai = ($a2["name"]=="Hentai" ? " <font color=red>(+18)</font> <img src='pic/buttons/uncensored.gif' />" : "");
$res2 = mysql_query("SELECT fansubbers.name as f_name, fansubbers.tag AS f_tag, fansubbers.id AS f_id FROM fansubbers
LEFT JOIN torrents ON torrents.fansubber = fansubbers.id WHERE torrents.id =" . $a["id"] . "")
or sqlerr();
$row2 = mysql_fetch_assoc($res2);
$res3 = mysql_query("SELECT estado.image AS est_image, estado.name AS est_name FROM estado LEFT JOIN torrents ON torrents.status = estado.id WHERE torrents.id = $id")
or sqlerr();
$row3 = mysql_fetch_assoc($res3);
if ($a[status] == 1)
$est_proj = ("<img title='Projecto concluído' src=pic/concluido.gif>\n");
elseif ($a[status] == 2)
$est_proj = ("<img title='Projecto em andamento' src=pic/em_andamento.gif>\n");
elseif ($a[status] == 3)
$est_proj = ("<img title='Projecto parado' src=pic/parado.gif>\n");
elseif ($a[status] == 4)
$est_proj = ("<img title='Projecto cancelado' src=pic/warned2.gif>\n");
elseif ($a[status] == 5)
$est_proj = ("<img title='Projecto terminado' src=pic/terminado.gif>\n");
elseif ($a[status] == 6)
$est_proj = ("<img title='Especiais apenas' src=pic/starb.gif>\n");
elseif ($a[status] == 7)
$est_proj = ("<img title='Projecto com estado desconhecido' src=pic/desconhecido.gif>\n");
elseif ($a[status] == 8)
$est_proj = ("<img title=src=pic/+.gif>\n");
else
$est_proj = ("$est_proj\n");
if (($a["name"]) == ($a["nameorig"]))
$dispname = htmlspecialchars($a["nameorig"]);
else
$dispname = htmlspecialchars($a["nameorig"]) ." <br> ". htmlspecialchars($a["name"]);
$data = mysql_query("SELECT size * times_completed AS data FROM torrents WHERE id = '$a[id]'") or sqlerr(__FILE__, __LINE__);
$b = mysql_fetch_assoc($data);
$data = mksize($b["data"]) . "";
$resbook = mysql_query("SELECT bookmarks.id, bookmarks.torrentid, bookmarks.userid, bookmarks.local, bookmarks.visto
FROM bookmarks LEFT JOIN torrents ON bookmarks.torrentid = torrents.id
WHERE bookmarks.userid = $id AND torrents.id = $a[id] AND bookmarks.id = $a[bid]") or sqlerr();
$rowbook = mysql_fetch_assoc($resbook);
{
{
if ($rowbook["local"] =="--")
$marcalocal = ("");
elseif ($rowbook["local"] =="Disco")
$marcalocal = ("<img src=pic/buttons/state_onhdd.gif border=0 title='Projecto " .$a["nameorig"]. " guardado em Disco'>\n");
elseif ($rowbook["local"] =="CD/DVD")
$marcalocal = ("<img src=pic/buttons/state_oncd.gif border=0 title='Projecto " .$a["nameorig"]. " guardado em CD/DVD'>\n");
else
$marcalocal = ("\n");
}
{
if ($rowbook["visto"] =="--")
$marcavisto = ("");
elseif ($rowbook["visto"] =="completo")
$marcavisto = ("<img src=pic/buttons/seen.gif border=0 title='Projecto " .$a["nameorig"]. " visto na totalidade'>\n");
elseif ($rowbook["visto"] =="parte")
$marcavisto = ("<img src=pic/buttons/seeing.gif border=0 title='Projecto " .$a["nameorig"]. " visto em parte'>\n");
elseif ($rowbook["visto"] =="nunca")
$marcavisto = ("<img src=pic/buttons/seen_no.gif border=0 title='Projecto " .$a["nameorig"]. " nunca visto'>\n");
else
$marcavisto = ("\n");
}
}
$torrents .= "<tr class=tableb>
<td align=center><a class=altlink href=details.php?id=" . $a["id"] . "&hit=1><img border='0' title='Ver detalhes do projecto: ". $a["nameorig"] . "' src=pic/buttons/m_info.gif></a></td>
<td align=center> <a class=altlink href=details.php?id=" . $a["id"] . "&hit=1><b><font color=black>$dispname</font></b></a> $ishentai </td>
<td align=center>$marcalocal $marcavisto</td>
<td align=center>$cat</td>
<td align=center><b>" . $a["ano"] . "</b></td>
<td align=center><b>" . $a["epsl"] . " / " . $a["epst"] . "</b></td>
<td align=center>$est_proj</td>
<td align=center><b><a href=\"files.php?id=$a[id]&hit=1&filelist=1\">" . $a["numfiles"] . "</a> / " . str_replace(" ", " ", mksize($a["size"])) . "</b></td>
<td align=center><a href=\"fansubbersdetails.php?id=". $row2["f_id"] ."\" class=altlink><b><font color=black>[" . $row2["f_tag"] . "]</font></b></a></td>
</tr>\n";
}
$torrents .= "</table>";
}
}
#Início do print
if (!$torrents)
print("<table align=center cellpadding=5><td align=center><b>Sem entradas</b><br></td></table>\n");
else if ($count) {
if (strlen($letter) > 1)
die;
if ($letter == "" || strpos("abcdefghijklmnopqrstuvwxyz", $letter) === false)
$letter = "";
$query = "torrents.nameorig LIKE '$letter%'";
$q = "letter=$letter";
print("$torrents\n");
print("<p align=center><a href=#top class=altlink>Voltar ao topo da lista</a></p>");
}
print("</table>\n");
stdfoot();
?>
[/HIDE]