Problem med gæstebog
<html><head>
<link rel="stylesheet" type="text/css" href="../style/Pink_version2.css">
</head>
<body>
<?
$db = mysql_connect("****", "****", "****");
mysql_select_db("****");
if ($_POST["skriv"]){
$navn = $_POST["navn"];
$email = $_POST["email"];
$hjemmeside = $_POST["hjemmeside"];
$hjemmeside = "<a href=\"http://".$hjemmeside."\" target=\"_blank\">".$hjemmeside."</a>";
$besked = $_POST["besked"];
if($besked==null){
echo "<font class=\"indhold3\"><b>Beklager, men du kan ikke poste en tom besked</b></font>";
} else {
if(!get_magic_quotes_gpc()){
$navn = addslashes($navn);
$email = addslashes($email);
$hjemmeside = addslashes($hjemmeside);
$besked = addslashes($besked);
}
$dato_array = getdate();
if($dato_array["minutes"]<10)
{
$minutes = "0".$dato_array["minutes"];
} else
{
$minutes = $dato_array["minutes"];
}
$dato = $dato_array["mday"]. "/".
$dato_array["mon"]. "/".
$dato_array["year"]. " ".
$dato_array["hours"]. ":".
$minutes;
mysql_query("INSERT INTO gbog (navn, email, hjemmeside, dato, besked) VALUES ('$navn', '$email', '$hjemmeside', '$dato', '$besked')");
}
}
class Pager
{
function getPagerData($numHits, $limit, $page)
{
$numHits = (int) $numHits;
$limit = max((int) $limit, 1);
$page = (int) $page;
$numPages = ceil($numHits / $limit);
$page = max($page, 1);
$page = min($page, $numPages);
$offset = ($page - 1) * $limit;
$ret = new stdClass;
$ret->offset = $offset;
$ret->limit = $limit;
$ret->numPages = $numPages;
$ret->page = $page;
return $ret;
}
}
?>
<script type="text/javascript">
<!--
function storeCaret(textEl)
{
if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}
function insertAtCaret(textEl, text)
{
if (textEl.createTextRange && textEl.caretPos)
{
var caretPos = textEl.caretPos;
caretPos.text = (caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text);
}
else
{
textEl.value = textEl.value + text;
}
textEl.focus();
}
//-->
</script>
<table width="660" height="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><table width="660" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="430">
<table width="430" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div class="indhold2"><b>Skriv i gæstebogen</b> </div><br></td>
</tr>
<tr>
<td valign="top">
<FORM method="post" action="<? echo $PHP_SELF; ?>">
<INPUT type="hidden" name="skriv" value="1">
<INPUT name="navn" value="Navn" onFocus="if(this.value==this.defaultValue) { this.value=''; }" onBlur="if(this.value=='') { this.value=this.defaultValue; }">
<INPUT name="email" value="Email" onFocus="if(this.value==this.defaultValue) { this.value=''; }" onBlur="if(this.value=='') { this.value=this.defaultValue; }">
<INPUT name="hjemmeside" value="Hjemmeside" onFocus="if(this.value==this.defaultValue) { this.value=''; }" onBlur="if(this.value=='') { this.value=this.defaultValue; }">
<div class="indhold"><b>Besked</b></div>
<textarea name="besked" ID="txtBody" cols="80" rows="10" tabindex="1" wrap="virtual" style="width:430;"></textarea>
<input type="submit" name="Skriv" value="Skriv" tabindex="1" style="width:430;" /></FORM>
</td>
</tr>
<tr>
<td height="10"></td>
</tr>
<tr>
<td valign="top">
<img alt=":-) Glad"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-) ');" src="smilie/smile.gif" style="cursor: hand; cursor: pointer" title=":-) Glad" width="16">
<img alt=":-D Griner"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-D ');" src="smilie/biggrin.gif" style="cursor: hand; cursor: pointer" title=":-D Griner" width="16">
<img alt="8-< Underlig"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' 8-< ');" src="smilie/weird.gif" style="cursor: hand; cursor: pointer" title="8-) underlig" width="16">
<img alt=":-o Overrasket"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-o ');" src="smilie/amazed.gif" style="cursor: hand; cursor: pointer" title=":-o Overrasket" width="16">
<img alt=":-, Underholde"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-, ');" src="smilie/amuse.gif" style="cursor: hand; cursor: pointer" title=":-, Underholde" width="16">
<img alt=":-[ Sur"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-[ ');" src="smilie/angry.gif" style="cursor: hand; cursor: pointer" title=":-[ Sur" width="16">
<img alt="!-) Totalt"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' !-) ');" src="smilie/Totalt.gif" style="cursor: hand; cursor: pointer" title="!-) Totalt" width="16">
<img alt=";-) Lidtskør"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' ;-) ');" src="smilie/cheesy.gif" style="cursor: hand; cursor: pointer" title=";-) Lidtskør" width="16">
<img alt="?-/ Forvirret"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' ?-/ ');" src="smilie/confused.gif" style="cursor: hand; cursor: pointer" title="?-/ Forvirret" width="16">
<img alt="+-) Cool"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' +-) ');" src="smilie/cool.gif" style="cursor: hand; cursor: pointer" title="+-) Cool" width="16">
<img alt="?-) Skør"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' ?-) ');" src="smilie/crazy.gif" style="cursor: hand; cursor: pointer" title="?-) Skør" width="16">
<img alt=":-( Græde"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-( ');" src="smilie/crying.gif" style="cursor: hand; cursor: pointer" title=":-( Græde" width="16">
<img alt="#-] Flov"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' #-] ');" src="smilie/embarrest.gif" style="cursor: hand; cursor: pointer" title="#-] Flov" width="16">
<img alt="¤-] Ond"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' ¤-] ');" src="smilie/evil.gif" style="cursor: hand; cursor: pointer" title="¤-] Ond" width="16">
<img alt="%-/ Huh"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' %-/ ');" src="smilie/huh.gif" style="cursor: hand; cursor: pointer" title="%-/ Huh" width="16">
<img alt=":-> Grine"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-> ');" src="smilie/laugh.gif" style="cursor: hand; cursor: pointer" title=":-> Grine" width="16">
<img alt="!-, stolikke"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' !-, ');" src="smilie/notrust.gif" style="cursor: hand; cursor: pointer" title="!-, ikkestole" width="16">
<img alt=">-, ikkebekymret"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' >-, ');" src="smilie/noworry.gif" style="cursor: hand; cursor: pointer" title=">-, ikkebekymret" width="16">
<br>
<img alt=":-& Oh"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-& ');" src="smilie/oh.gif" style="cursor: hand; cursor: pointer" title=":-& Oh" width="16">
<img alt=">-o Skubbe"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' >-o ');" src="smilie/push.gif" style="cursor: hand; cursor: pointer" title=">-o Skubbe" width="16">
<img alt="&-) Rundeojne"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' &-) ');" src="smilie/rolleyes.gif" style="cursor: hand; cursor: pointer" title="&-) Rundeojne" width="16">
<img alt=":-c Trist"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-c ');" src="smilie/sad.gif" style="cursor: hand; cursor: pointer" title=":-c Trist" width="16">
<img alt="=-)2 Speciel2"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' =-)2 ');" src="smilie/special2.gif" style="cursor: hand; cursor: pointer" title="=-)2 Speciel2" width="16">
<img alt=":-; Tunge"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-; ');" src="smilie/tongue.gif" style="cursor: hand; cursor: pointer" title=":-; Tunge" width="16">
<img alt="=-/ Usikker"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' =-/ ');" src="smilie/unsure.gif" style="cursor: hand; cursor: pointer" title="=-/ Usikker" width="16">
<img alt="!-; Vink"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' !-; ');" src="smilie/wink.gif" style="cursor: hand; cursor: pointer" title="!-; Vink" width="16">
<img alt=":-{ Gal"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-{ ');" src="smilie/mad.gif" style="cursor: hand; cursor: pointer" title=":-{ Gal" width="16">
<img alt=":-<3 Hjerte"
border="0" height="14" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-<3 ');" src="smilie/love.gif" style="cursor: hand; cursor: pointer" title=":-<3 Hjerte" width="16">
<img alt="<!!!> Vigtigt"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' <!!!> ');" src="smilie/important.gif" style="cursor: hand; cursor: pointer" title="<!!!> Vigtigt" width="16">
<img alt="(???) Spaargsmaal"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' (???) ');" src="smilie/question.gif" style="cursor: hand; cursor: pointer" title="(???) Spaargsmaal" width="16">
<img alt="<&&&> Bange"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' <&&&> ');" src="smilie/special1.gif" style="cursor: hand; cursor: pointer" title="<&&&> Bange" width="16">
<img alt="(///) Syg"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' (///) ');" src="smilie/sick.gif" style="cursor: hand; cursor: pointer" title="(///) Syg" width="16">
</td>
</tr>
<tr>
<td>
<?
$antal = 10;
if(!$start || $start < 0) { $start = 0; }
$foresp = mysql_query("SELECT navn, email, hjemmeside, dato, besked FROM gbog ORDER BY nr DESC LIMIT $start, $antal") or die (mysql_error());
while($data = mysql_fetch_array($foresp)){
echo "<tr><td class='indhold' valign=\"top\" width=\"430\">";
echo "fra: <a href=\"mailto:";
echo $data["email"];
echo "\">";
echo $data["navn"];
echo "</a>"." ";
echo $data["dato"]. " ";
echo $data["hjemmeside"];
echo "<hr width=\"100%\" size=\"1\" color=\"#FFFFFF\" noshade>";
$temp=str_replace(":-)","<img src=\"smilie/smile.gif\">",nl2br($data["besked"]));
$temp=str_replace(":-D","<img src=\"smilie/biggrin.gif\">",$temp);
$temp=str_replace("8-<","<img src=\"smilie/weird.gif\">",$temp);
$temp=str_replace(":-o","<img src=\"smilie/amazed.gif\">",$temp);
$temp=str_replace(":-,","<img src=\"smilie/amuse.gif\">",$temp);
$temp=str_replace(":-[","<img src=\"smilie/angry.gif\">",$temp);
$temp=str_replace("!-)","<img src=\"smilie/Totalt.gif\">",$temp);
$temp=str_replace(";-)","<img src=\"smilie/cheesy.gif\">",$temp);
$temp=str_replace("?-/","<img src=\"smilie/confused.gif\">",$temp);
$temp=str_replace("+-)","<img src=\"smilie/cool.gif\">",$temp);
$temp=str_replace("?-)","<img src=\"smilie/crazy.gif\">",$temp);
$temp=str_replace(":-(","<img src=\"smilie/crying.gif\">",$temp);
$temp=str_replace("#-]","<img src=\"smilie/embarrest.gif\">",$temp);
$temp=str_replace("¤-]","<img src=\"smilie/evil.gif\">",$temp);
$temp=str_replace("%-/","<img src=\"smilie/huh.gif\">",$temp);
$temp=str_replace(":->","<img src=\"smilie/laugh.gif\">",$temp);
$temp=str_replace("!-,","<img src=\"smilie/notrust.gif\">",$temp);
$temp=str_replace(">-,","<img src=\"smilie/noworry.gif\">",$temp);
$temp=str_replace(":-&","<img src=\"smilie/oh.gif\">",$temp);
$temp=str_replace(">-o","<img src=\"smilie/push.gif\">",$temp);
$temp=str_replace("&-)","<img src=\"smilie/rolleyes.gif\">",$temp);
$temp=str_replace(":-c","<img src=\"smilie/sad.gif\">",$temp);
$temp=str_replace("=-)2","<img src=\"smilie/special2.gif\">",$temp);
$temp=str_replace(":-;","<img src=\"smilie/tongue.gif\">",$temp);
$temp=str_replace("=-/","<img src=\"smilie/unsure.gif\">",$temp);
$temp=str_replace("!-;","<img src=\"smilie/wink.gif\">",$temp);
$temp=str_replace(":-{","<img src=\"smilie/mad.gif\">",$temp);
$temp=str_replace(":-<3","<img src=\"smilie/love.gif\">",$temp);
$temp=str_replace("<!!!>","<img src=\"smilie/important.gif\">",$temp);
$temp=str_replace("(???)","<img src=\"smilie/question.gif\">",$temp);
$temp=str_replace("<&&&>","<img src=\"smilie/special1.gif\">",$temp);
$temp=str_replace("(///)","<img src=\"smilie/sick.gif\">",$temp);
echo $temp;
echo "<hr width=\"430\" size=\"1\" align=\"left\" color=\"#C0C0C0\" noshade>";
echo "</tr>";
echo "</td>";
}
?>
</td>
</tr>
<tr>
<td>
<?php
// get the pager input values
$page = $_GET['page'];
$limit = 10;
$result = mysql_query("select count(*) from gbog");
$total = mysql_result($result, 0, 0);
// work out the pager values
$pager = Pager::getPagerData($total, $limit, $page);
$offset = $pager->offset;
$limit = $pager->limit;
$page = $pager->page;
// use pager values to fetch data
$query = "select * from gbog order by someField limit $offset, $limit";
$result = mysql_query($query);
// use $result here to output page content
// output paging system (could also do it before we output the page content)
if ($page == 1) // this is the first page - there is no previous page
echo "Previous";
else // not the first page, link to the previous page
echo "<a href=\"gaestebog.php?page=" . ($page - 1) . "\">Previous</a>";
for ($i = 1; $i <= $pager->numPages; $i++) {
echo " | ";
if ($i == $pager->page)
echo "Page $i";
else
echo "<a href=\"gaestebog.php?page=$i\">Page $i</a>";
}
if ($page == $pager->numPages) // this is the last page - there is no next page
echo "Next";
else // not the last page, link to the next page
echo "<a href=\"gaestebog.php?page=" . ($page + 1) . "\">Next</a>";
?>
</td>
</tr>
</table>
</td>
<td width="230"></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Her er min næsten fulde gæstebog, der er bare en fejl med den og det er at det skal fungere sådan, at når man har skrevet 10 beskeder i gæstebogen, så skifter den automatisk så den viser f.eks. hvis der er 10 beskeder viser den kun en side altså nederst og så hvis der er 20 beskeder så viser den 2 sider så man kan vælge at se begge sider ved at trykke på side 1 eller 2 eller næste eller forrige.. den kan sagtens vise siderne, MEN det er kun beskederne fra side 1 som bliver vist.. altså hvis jeg går ind på side 2 eller 3 vil den kun vise beskederne fra side 1..
hvad mangler jeg eller hvad skal der rettes.. nogen som kan løse dette problem for mig...??
MVH futte
