Forum help
Ik heb een forum op mijn site en heb 2 tables
en tables met de topics en een table met replys
dan heb ik een pagina die er zo uit ziet
================================
DE TOPICS INHOUD LEEST HIJ UIT TABLE TOPIC
================================
Hier zet hij alle replys die bij deze topics horen
================================
Om de replys te lezen gebruik ik dit:
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
34
35
36
37
38
39
40
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
34
35
36
37
38
39
40
<?
echo "<tr><td width=\"100%\" colspan=\"2\"><table align=\"center\" border=\"0\" cellspacing=\"0\" cellpading=\"0\" width=\"100%\"><tr><td class=\"menu\" width=\"100%\">
<b>Replys</b></td>
</tr></table></tr>";
$csql = "SELECT naam,bericht,datum FROM replys WHERE tid = '$_GET[id]' ORDER BY `id` asc ";
$cres = mysql_query($csql);
if (mysql_num_rows($cres) >= 1)
{
while ($row = mysql_fetch_array($cres))
{
$dbh=mysql_connect("","","");
$res2=mysql_db_query("","select signature from members WHERE user='$row[naam]';",$dbh);
$row2=mysql_fetch_row($res2);
$res3=mysql_db_query("","select count(id) from topics WHERE naam='$row[naam]';",$dbh);
$row3=mysql_fetch_row($res3);
$res4=mysql_db_query("","select count(id) from replys WHERE naam='$row[naam]';",$dbh);
$row4=mysql_fetch_row($res4);
echo "<tr><td width=\"100%\" colspan=\"2\"><table align=\"center\" border=\"0\" cellspacing=\"0\" cellpading=\"0\" width=\"100%\"><tr><td class=\"menu\" width=\"100%\" align=\"right\">$row[datum]</td>
</tr></table></tr>";
$row[bericht] = nl2br($row[bericht]);
$row[bericht] = smilie($row[bericht]);
echo "<tr><td width=\"100%\" colspan=\"2\"><table align=\"center\" border=\"0\" cellspacing=\"0\" cellpading=\"0\" width=\"100%\"><tr><td class=\"menu\" width=\"150\" valign=\"top\"><a href=\"vieuw_members.php?a=$row[naam]\">$row[naam]</a><br>Posts: $row3[0]<br>Replys: $row4[0]</td><td class=\"menu\">$row[bericht]<hr color=\"000080\">$row2[0]</td></tr></table></td></tr>";
}
}
else
{
echo "<tr><td width=\"100%\" colspan=\"2\"><table align=\"center\" border=\"0\" cellspacing=\"0\" cellpading=\"0\" width=\"100%\"><tr><td class=\"menu\" width=\"100%\">
<b>No replys</b></td>
</tr></table></tr>";
}
?>
echo "<tr><td width=\"100%\" colspan=\"2\"><table align=\"center\" border=\"0\" cellspacing=\"0\" cellpading=\"0\" width=\"100%\"><tr><td class=\"menu\" width=\"100%\">
<b>Replys</b></td>
</tr></table></tr>";
$csql = "SELECT naam,bericht,datum FROM replys WHERE tid = '$_GET[id]' ORDER BY `id` asc ";
$cres = mysql_query($csql);
if (mysql_num_rows($cres) >= 1)
{
while ($row = mysql_fetch_array($cres))
{
$dbh=mysql_connect("","","");
$res2=mysql_db_query("","select signature from members WHERE user='$row[naam]';",$dbh);
$row2=mysql_fetch_row($res2);
$res3=mysql_db_query("","select count(id) from topics WHERE naam='$row[naam]';",$dbh);
$row3=mysql_fetch_row($res3);
$res4=mysql_db_query("","select count(id) from replys WHERE naam='$row[naam]';",$dbh);
$row4=mysql_fetch_row($res4);
echo "<tr><td width=\"100%\" colspan=\"2\"><table align=\"center\" border=\"0\" cellspacing=\"0\" cellpading=\"0\" width=\"100%\"><tr><td class=\"menu\" width=\"100%\" align=\"right\">$row[datum]</td>
</tr></table></tr>";
$row[bericht] = nl2br($row[bericht]);
$row[bericht] = smilie($row[bericht]);
echo "<tr><td width=\"100%\" colspan=\"2\"><table align=\"center\" border=\"0\" cellspacing=\"0\" cellpading=\"0\" width=\"100%\"><tr><td class=\"menu\" width=\"150\" valign=\"top\"><a href=\"vieuw_members.php?a=$row[naam]\">$row[naam]</a><br>Posts: $row3[0]<br>Replys: $row4[0]</td><td class=\"menu\">$row[bericht]<hr color=\"000080\">$row2[0]</td></tr></table></td></tr>";
}
}
else
{
echo "<tr><td width=\"100%\" colspan=\"2\"><table align=\"center\" border=\"0\" cellspacing=\"0\" cellpading=\"0\" width=\"100%\"><tr><td class=\"menu\" width=\"100%\">
<b>No replys</b></td>
</tr></table></tr>";
}
?>
=================================
Dit werkt allemaal nu mijn vraag is hoe kan ik het script aanpassen zodat hij maar 20 replys toont per pagina en dat hij per reply een table style gebruikt.
V.b.
1. reply is <td class="light">
2. reply is <td class="dark">
3. en zo maar herhalen
=================================
als iemand zou kunnen helpen zeer bedankt
Code (php)
1
2
3
2
3
<?
$csql = "SELECT naam,bericht,datum FROM replys WHERE tid = '$_GET[id]' ORDER BY `id` asc LIMIT 0, 20 ";
?>
$csql = "SELECT naam,bericht,datum FROM replys WHERE tid = '$_GET[id]' ORDER BY `id` asc LIMIT 0, 20 ";
?>
Dat van die style weet ik niet op dit moment.
Veel succes
weet er dan niemand hoe je voor elke reply een andere style kan gebruiken
{
if (!$bgcolor || $bgcolor == "#eenkleur")
{
$bgcolor = "#eenandere";
}
else
{
$bgcolor = "#eenkleur";
}
echo "<td bgcolor=\"$bgcolor\">blaat</td>";
}
ik denk dat je dit zoekt
while ($row = mysql_fetch_array($res))
{
if (!$stijl|| $stijl == "#stijl")
{
$bgcolor = "#stijl";
}
else
{
$bgcolor = "#stijl 1";
}
echo "<td class=\"$stijl\">blaat</td>";
}
het werkt