...

View Full Version : I'm stuck



Snarf128
05-19-2004, 11:25 PM
I I have been working on a script that only allows a certain amount of rows on the screen and the rest is available by a next link yet somehow it just doesnt work can anyone tell what i did wrong.

<?php
// verbinding met database invoegen
include("inc_connect.php");
//database lezen
$pos = isset($pos) ? $pos : 0;
$count = 20;
$query = "SELECT * FROM tablename ORDER BY ID ASC LIMIT $pos,$count";
$result = mysql_query($query);
//records tellen
$data = mysql_num_rows(mysql_query("SELECT ID FROM tablename"));
//hyperlinks aanmaken
$next_n = $pos + $count;
if($next_n >= $data) {
$next_l = "volgende >>";
} else {
$next_l = "<a href=test.php?pos=" . $next_n . ">volgende >></a>";
}
$prev_n = $pos - $count;
if($prev_n < 0) {
$prev_l = "<< vorige";
} else {
$prev_l = "<a href=test.php?pos=" . $prev_n . "><< vorige</a>";
}
?>

<html>
<head>
<title>Overzicht werkdagen</title>
</head>
<table border="1" cellpadding="2" cellspacing="2" width="90% align="center">
<tr>
<th scope="col">Weeknr.</th>
<th scope="col">Datum</th>
<th scope="col">Tijd</th>
<th scope="col">Personeelsaam</th>
<th scope="col">Locatie</th>
<th scope="col">Werk</th>
<th scope="col">Bijzonderheden</th>
</tr>
<?
while($record = mysql_fetch_object($result))
{
echo"
<tr>

<td><b>$record->week</b></td>
<td><i>$record->dag $record->maand $record->jaar</i></td>
<td>$record->begin - $record->eind</td>
<td><b>$record->naam</b></td>
<td>$record->locatie</td>
<td>$record->werk</td>
<td>$record->bijz</td>
</tr>";
}
?>
</table>
<center><?php echo $prev_l . " " . $next_l ?>
<body>











</body>
</html>

Hawkmoon
05-20-2004, 01:42 AM
The way you have it now $pos will always be "0". You need the line:

$pos = $_GET['pos'];

to grab the value from the url.

Spookster
05-20-2004, 06:40 AM
You need to read our posting guidelines section 2

http://www.codingforums.com/postguide.htm

Snarf128
05-20-2004, 10:22 AM
thank you that helped a lot got it working now.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum