Meerdere pagina's na bijv 10 records
iemand een idee?
mijn code..
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
$query_comments = ("SELECT * FROM comments WHERE message_id=".$id." ORDER BY datum DESC");
$result_comments = mysql_query($query_comments)or die (mysql_error());
while($data_comments = mysql_fetch_array($result_comments)){
echo "<table width=\"400\" height=\"25\" border=\"1\" cellspacing=\"1\" bordercolor=\"#000000\">
<tr>
<td width=\"565\"><table width=\"400\" border=\"0\" cellspacing=\"0\">
<tr>
<td background=\"images/fade.gif\" height=\"20\" align=\"left\" valign=\"top\"><div id=\"feeter\">".$data_comments['naam']. " schreef op ".date("d-m-Y H:i:s", strtotime($data_comments['datum']))."</div></td>
<td width=\"171\" align=\"right\" valign=\"top\" background=\"images/fade.gif\"><a href=\"report.php?id=".$data_comments['id']."\"><img src=\"images/report.gif\" height=\"10\" alt=\"meld misbruik\" border=\"0\"></td
</tr>
<tr>
<td align=\"left\" valign=\"top\"><div id=\"content\">".nl2br($data_comments['comment'])."</div></td>
</tr>
<tr>
<td background=\"images/fade_invert.gif\" height=\"25\"> </td>
<td width=\"171\" align=\"left\" valign=\"top\" background=\"images/fade_invert.gif\"></td>
</tr>
</table></td>
</tr>
</table><BR>";
}
if (mysql_num_rows($result_comments) == 0){
echo "<div id=\"content\">Er is nog niet gereageerd op dit bericht.</div>";
}
?>
$query_comments = ("SELECT * FROM comments WHERE message_id=".$id." ORDER BY datum DESC");
$result_comments = mysql_query($query_comments)or die (mysql_error());
while($data_comments = mysql_fetch_array($result_comments)){
echo "<table width=\"400\" height=\"25\" border=\"1\" cellspacing=\"1\" bordercolor=\"#000000\">
<tr>
<td width=\"565\"><table width=\"400\" border=\"0\" cellspacing=\"0\">
<tr>
<td background=\"images/fade.gif\" height=\"20\" align=\"left\" valign=\"top\"><div id=\"feeter\">".$data_comments['naam']. " schreef op ".date("d-m-Y H:i:s", strtotime($data_comments['datum']))."</div></td>
<td width=\"171\" align=\"right\" valign=\"top\" background=\"images/fade.gif\"><a href=\"report.php?id=".$data_comments['id']."\"><img src=\"images/report.gif\" height=\"10\" alt=\"meld misbruik\" border=\"0\"></td
</tr>
<tr>
<td align=\"left\" valign=\"top\"><div id=\"content\">".nl2br($data_comments['comment'])."</div></td>
</tr>
<tr>
<td background=\"images/fade_invert.gif\" height=\"25\"> </td>
<td width=\"171\" align=\"left\" valign=\"top\" background=\"images/fade_invert.gif\"></td>
</tr>
</table></td>
</tr>
</table><BR>";
}
if (mysql_num_rows($result_comments) == 0){
echo "<div id=\"content\">Er is nog niet gereageerd op dit bericht.</div>";
}
?>
ik hoop het dat zoek ik ook
Dus even abstract:
query
- $start = $_GET['pagina'] * 10;
- SELECT * FROM tabel LIMIT $start, 10
links
- SELECT COUNT(*) AS aantal FROM tabel
- $aantal_paginas = ceil($fetch->aantal / 10)
- for ($i = 1; $i <= $aantal_paginas; $i++)
Gewijzigd op 01/01/1970 01:00:00 door PHP erik
Ik heb het script gebruikt een paar topics hierboven en dit werkt perfect. (zelfde principe eignelijk!) bedankt!