Er der en der tør .........
give mig et bud på hvordan jeg får det her script til at bruge paging ? Lige nu listes ALLE link i en katagori op under hindanden, hvilket jo er godt nok, men ikke hvis der er 200 link i samme kategori ???Jeg har ikke skrevet det selv, men downloaded det, og er blevet helt glad for det så jeg kunne dælens godt tænke mig en løsning.
Koden er her -
<?
// Configuration file
require ("config.inc.php");
require ("$lib/lib.php");
// Library files
include ("$lib/formlib.php");
// If the visitor will be transferred to an URL
if ($go) {
dbconnect ();
//Fýnd the hits of that page
$result = mysql_query("SELECT link_url, link_hits FROM $t_links WHERE link_id = '$go'");
while ($row = mysql_fetch_array($result))
{
$hits = $row["link_hits"];
$url = $row["link_url"];
}
// Increase hits
$hits++;
$result2 = @mysql_query("UPDATE $t_links SET link_hits = '$hits' WHERE link_id = '$go'");
header("Location: $url");
exit;
}
// If the user rates;
if ($action == "rate") {
// Set cookie, so he/she can't rate more than once'
$cookie = "dcp_rate" . $id;
dbconnect ();
$result = mysql_query("SELECT link_totalrate, link_numvotes, link_cat FROM $t_links WHERE link_id = '$id'");
while ($row = mysql_fetch_array($result))
{
$numvotes = $row["link_numvotes"];
$totalrate = $row["link_totalrate"];
$cat = $row["link_cat"];
}
// If voted before, go back
if ($$cookie == "yes")
{
header("Location: $root_url/links.php?licat_id=$cat");
exit;
}
// If not, increase numver of votes and add the rate to total rate
$numvotes++;
$totalrate = $totalrate + $score;
$result2 = @mysql_query("UPDATE $t_links SET link_numvotes = '$numvotes', link_totalrate = '$totalrate' WHERE link_id = '$id'");
setcookie($cookie, "yes", time() + 360000);
// Go back to the page
header("Location: $root_url/links.php?licat_id=$cat");
exit;
}
//Print navigation bar
$page_code = "links";
$page_name = LANG_LINKS;
require ("$lib/themelib.php");
echo siteTheme ("header");
if ($action == "add") {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="100%" colspan="2"><img src="<?=$images?>/ico_news.gif" width="20" height="20"><b><?=LANG_LINKS?></b></td>
</tr>
<tr valign="top">
<td width="100%" bgcolor="<?=$subject_color?>" colspan="2"><img src="<?=$images?>/spc.gif" width="1" height="1"></td>
</tr>
<tr valign="top">
<td width="100%" colspan="2"><img src="<?=$images?>/spc.gif" width="1" height="5"></td>
</tr>
<tr valign="top">
<form action=<?=$root_url?>/links.php method=get>
<td width="100%" colspan="2"><div align="center"><b><?=LANG_SEARCHLINKS?>:</b>
<input type="test" size="20" name="linksearch" class="button">
<input type="hidden" name="action" value="search"> <input type=submit value=OK class="button"><p>
</div></td>
</form>
</tr>
<tr valign="top">
<form name="form1" method="post" action="<?=$root_url?>/links.php">
<td width="100%" colspan="2"><img src="<?=$images?>/spc.gif" width="1" height="5"></td>
</tr>
<tr valign="top">
<td width="100%" colspan="2"><b><font size="2"><?=LANG_SUBMITLINKS?></b></td>
</tr>
<tr valign="top">
<td width="100%" bgcolor="<?=$subject_color?>" colspan="2"><img src="<?=$images?>/spc.gif" width="1" height="1"></td>
</tr>
<? if ((!$mode) || ((($mode == "send") && (($add_link_name == "") || ($add_link_desc == "") || ($add_link_url == ""))))) { ?>
<tr valign="top">
<td width="200"><b><?=LANG_LINKNAME?>:</b></td>
<td width="400"><input type="text" name="add_link_name" size="20" value="<?=$add_link_name?>" class="button" maxlength="100">
<? CheckFields ($add_link_name, "Link Adý", $mode) ?></td>
</tr>
<tr valign="top">
<td width="200"><b><?=LANG_DESC?>:</b></td>
<td width="400"><input type="text" name="add_link_desc" size="20" value="<?=$add_link_desc?>" class="button" maxlength="100">
<? CheckFields ($add_link_desc, "Link Açýklamasý", $mode) ?></td>
</tr>
<tr valign="top">
<td width="200"><b><?=LANG_LINKURL?>:</b></td>
<td width="400"><input type="text" name="add_link_url" size="20" value="<?=$add_link_url?>" class="button" maxlength="100">
<? CheckFields ($add_link_url, "Link URL", $mode) ?></td>
</tr>
<tr valign="top">
<td width="200"><b><?=LANG_SENDER?>:</b></td>
<td width="400"><input type="text" name="add_link_addname" size="20" value="<?=$add_link_addname?>" class="button" maxlength="100"></td>
</tr>
<tr valign="top">
<td width="200"><b><?=LANG_EMAIL?>:</b></td>
<td width="400"><input type="text" name="add_link_addemail" size="20" value="<?=$add_link_addemail?>" class="button" maxlength="100">
<input type="hidden" name="add_link_cat" value="<?=$licat_id?>">
<input type="hidden" name="action" value="add">
<input type="hidden" name="mode" value="send"></td>
</tr>
<tr valign="top">
<td width="100%" colspan="2"><INPUT TYPE="SUBMIT" name="submit" value="OK" class="button"></td>
</tr>
<? } else if (($mode == "send") && ($add_link_name != "") && ($add_link_desc != "") && ($add_link_url != "")) { ?>
<?
dbconnect();
$time = time();
if (!$add_link_cat) {
$add_link_cat = "0";
}
$sql = "INSERT INTO $t_links
(link_cat, link_name, link_url, link_desc, link_dateadd, link_addname, link_addemail, link_validated, link_recommended)
VALUES
('$add_link_cat', '$add_link_name', '$add_link_url', '$add_link_desc', now(), '$add_link_addname', '$add_link_addemail', 'No', 'No') ";
$result = @mysql_query($sql)
or die ("Link kategorisi eklenemiyor");
$sql = "SELECT lcat_numlinks FROM $t_linkcat WHERE lcat_id = '$add_link_cat'";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
$numlinks = $row["lcat_numlinks"];
}
$numlinks++;
$sql = "UPDATE $t_linkcat SET
lcat_numlinks = '$numlinks' WHERE lcat_id = '$add_link_cat'";
$result = mysql_query($sql);
if ($warn_link == "1") {
@mail ("$admin_mail", LANG_MAIL_S_NEWLINK, LANG_MAIL_NEWLINK, "From:$admin_mail");
}
?>
<tr valign="top">
<td width="100%" colspan="2"><b><?=$add_link_name?></b> <?=LANG_ADDLINKMESSAGE?>.</td>
</tr>
<? } ?>
</form>
</table>
<?
} else {
// Select links under a category
// If no category selected, show main category
if (!$licat_id) {
$licat_id = "0";
}
// Select links
dbconnect();
$return = numlinks_array();
$numlinks = $return[0];
$numlinkstree = $return[1];
$result = mysql_query("SELECT lcat_id, lcat_name, lcat_ranking
FROM $t_linkcat WHERE lcat_cat = '$licat_id' ORDER BY lcat_ranking DESC, lcat_name");
$num = mysql_num_rows($result);
$i = 0;
while ($row = mysql_fetch_array($result))
{
$lcat_id = $row["lcat_id"];
$lcat_name = $row["lcat_name"];
$lcat_ranking = $row["lcat_ranking"];
$lcat_numlinks = $numlinks[$lcat_id];
$lcat_numlinkstree = $numlinkstree[$lcat_id];
if (!$lcat_numlinks) {
$lcat_numlinks = '0'; }
if (!$lcat_numlinkstree) {
$lcat_numlinkstree = '0'; }
$links .= "<td width=\"300\" valign=\"top\">· <b><a href=\"$root_url/links.php?licat_id=$lcat_id\">$lcat_name</a></b> ($lcat_numlinks/$lcat_numlinkstree)</td>";
$links .= "<td width=\"10\" valign=\"top\"><img src=\"$images/spc.gif\" width=\"10\" height=\"1\"></td>";
// Open new row after each 2 categories
$i++;
if (is_int($i / 2)) {
$links .= "</tr>";
$links .= "<tr>";
}
}
$result = mysql_query("SELECT lcat_name, lcat_header FROM $t_linkcat WHERE lcat_id = '$licat_id'");
while ($row = mysql_fetch_array($result))
{
$linkcat_name = $row["lcat_name"];
$linkcat_header = $row["lcat_header"];
}
$result = mysql_query("SELECT * FROM $t_links WHERE link_cat = '$licat_id' AND link_validated = 'Yes' AND link_recommended = 'No' ORDER BY link_name");
while ($row = mysql_fetch_array($result))
{
$lid = $row["link_id"];
$lname = $row["link_name"];
$lhits = $row["link_hits"];
$ldesc = $row["link_desc"];
$lurl = $row["link_url"];
$ltotalrate = $row["link_totalrate"];
$lnumvotes = $row["link_numvotes"];
$ldateadd = $row["link_dateadd"];
$ldateadd = localdate($ldateadd);
if ($lnumvotes > 0)
{
$avgrate = sprintf ("%.2f", ($ltotalrate / $lnumvotes));
}
$linkhtml .= "<tr><form action=$root_url/links.php method=post name=rate$lid>
<td><ul><li><a href=\"$root_url/links.php?go=$lid\" target=\"_blank\" onmouseout=\"window.status=' '; return true\" onmouseover=\"window.status='$lurl'; return true\">$lname</a>
<span class=small>[$lhits ".LANG_HITS.", $lnumvotes ".LANG_VOTES.", ".LANG_RATING." $avgrate]<br>
$ldesc
<b>".LANG_RATE.":<b><input type=hidden name=action value=rate>
<input type=hidden name=id value=$lid>
<select name=score size=1 class=button onchange=\"document.rate$lid.submit()\">
<option>-<option>1<option>2<option>3<option>4<option>5<option>6<option>7<option>8<option>9<option>10
</select></li></ul></td></form></tr>";
}
$result = mysql_query("SELECT * FROM $t_links WHERE link_cat = '$licat_id' AND link_validated = 'Yes' AND link_recommended = 'Yes' ORDER BY link_name");
while ($row = mysql_fetch_array($result))
{
$lid = $row["link_id"];
$lname = $row["link_name"];
$lhits = $row["link_hits"];
$ldesc = $row["link_desc"];
$lurl = $row["link_url"];
$ltotalrate = $row["link_totalrate"];
$lnumvotes = $row["link_numvotes"];
$ldateadd = $row["link_dateadd"];
$ldateadd = localdate($ldateadd);
if ($lnumvotes > 0)
{
$avgrate = sprintf ("%.2f", ($ltotalrate / $lnumvotes));
}
$linkhtmlrec .= "<tr><form action=$root_url/links.php method=post name=rate$lid>
<td><ul><li><font color=red><b>*</b></font><a href=\"$root_url/links.php?go=$lid\" target=\"_blank\" onmouseout=\"window.status=' '; return true\" onmouseover=\"window.status='$lurl'; return true\">$lname</a>
<span class=small>[$lhits ".LANG_HITS.", $lnumvotes ".LANG_VOTES.", ".LANG_RATING." $avgrate]<br>
$ldesc
<b>".LANG_RATE.":<b><input type=hidden name=action value=rate>
<input type=hidden name=id value=$lid>
<select name=score size=1 class=button onchange=\"document.rate$lid.submit()\">
<option>-<option>1<option>2<option>3<option>4<option>5<option>6<option>7<option>8<option>9<option>10
</select></li></ul></td></form></tr>";
}
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="100%" colspan="3"><img src="<?=$images?>/ico_news.gif" width="20" height="20"><b><?=LANG_LINKS?></b></td>
</tr>
<tr valign="top">
<td width="100%" bgcolor="<?=$subject_color?>" colspan="3"><img src="<?=$images?>/spc.gif" width="1" height="1"></td>
</tr>
<tr valign="top">
<td width="100%" colspan="3"><img src="<?=$images?>/spc.gif" width="1" height="5"></td>
</tr>
<tr valign="top">
<form action=<?=$root_url?>/links.php method=get>
<td width="100%" colspan="3"><div align="center"><b><?=LANG_SEARCHLINKS?>:</b>
<input type="test" size="20" name="linksearch" class="button">
<input type="hidden" name="action" value="search"> <input type=submit value=OK class="button"><p>
</div></td>
</form>
</tr>
<tr valign="top">
<td width="100%" colspan="3"><img src="<?=$images?>/spc.gif" width="1" height="5"></td>
</tr>
<? if (!$action) { ?>
<tr valign="top">
<? if ($licat_id != "0") { ?>
<tr valign="top">
<td width="100%" colspan="3"><img src="<?=$images?>/spc.gif" width="1" height="5"></td>
</tr>
<tr valign="top">
<td width="100%" colspan="3"><font size="2"><div align="center"><b><?=$linkcat_name?>:</b><br><?=$linkcat_header?></div></font></td>
</tr>
<? } ?>
<tr valign="top">
<td width="100%" colspan="3"><img src="<?=$images?>/spc.gif" width="1" height="5"></td>
</tr>
<tr valign="top">
<?=$links?>
<tr valign="top">
<td width="100%" colspan="3"><img src="<?=$images?>/spc.gif" width="1" height="5"></td>
</tr>
<?=$linkhtmlrec?>
<?=$linkhtml?>
<? } else if ($action == "search") { ?>
<tr valign="top">
<td width="100%" colspan="3"><img src="<?=$images?>/spc.gif" width="1" height="5"></td>
</tr>
<tr valign="top">
<td width="100%" colspan="3"><font size="2"><div align="center"><?=LANG_SEARCHRESULTSENG?> <b>"<?=$linksearch?>"</b> <?=LANG_SEARCHRESULTS?></div></font></td>
</tr>
<tr valign="top">
<td width="100%" colspan="3"><img src="<?=$images?>/spc.gif" width="1" height="5"></td>
</tr>
<?
dbconnect();
$link_sql = "SELECT * FROM $t_links WHERE link_validated = 'yes' AND
(link_name LIKE '%$linksearch%' OR link_desc LIKE '%$linksearch%')
ORDER BY link_name";
$cat_sql = "SELECT lcat_id, lcat_name, lcat_ranking FROM $t_linkcat WHERE
(lcat_name LIKE '%$linksearch%' OR lcat_header LIKE '%$linksearch%')
ORDER BY lcat_ranking DESC, lcat_name";
$link_result = links_sql($link_sql);
$cat_result = cats_sql($cat_sql);
if ((!$linksearch) || (!$link_result)) { ?>
<tr valign="top">
<td width="100%" colspan="3"><font size="2"><div align="center"><i><?=LANG_NOSEARCHRESULTS?></i></div></font></td>
</tr>
<?
} else {
echo "$cat_result";
?>
<tr valign="top">
<td width="100%" colspan="3"><img src="<?=$images?>/spc.gif" width="1" height="5"></td>
</tr>
<?
echo "$link_result";
}
?>
<? } ?>
<tr valign="top">
<td width="100%" colspan="3"><img src="<?=$images?>/spc.gif" width="1" height="5"></td>
</tr>
<tr valign="top">
<td width="100%" colspan="3"><b><div align="center"><a href="<?=$root_url?>/links.php?action=add"><?=LANG_SUBMITLINK?></a></div></b></td>
</tr>
<tr valign="top">
<td width="100%" colspan="3"><img src="<?=$images?>/spc.gif" width="1" height="5"></td>
</tr>
</table>
<? }
?>
<?
echo siteTheme ("footer");
?>
