Hoe meerdere regels uit de database halen.
Ik heb een forum.
en als ik er informatie uithaal dan word het niet in regels verdeeld maar word alles aanelkaar geplakt.
Weet iemand hoe dit komt ?
script:
<link href="/paginas/css/lettertypen.css" rel="stylesheet" type="text/css" />
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
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
<?php
error_reporting(E_ALL);
if ($_SESSION['user_ID'] == "")
{
print("<div align=\"center\"><span class=\"xbig\">Je bent niet ingelogd!</span><br /> <br /><span class=\"style4\"><a href=\"/paginas/login.php\">Hier</a> kun je je inloggen</span></div>");
exit;
}
//Informatie uit GET halen.
$topic_id = $_GET['topic_id'];
//verbinding maken met da database!
$dbc = mysql_connect('localhost', '****', '******´);
mysql_select_db('knorfski', $dbc);
//Query's aanmaken
$query1 = "select * from forum_inhoud WHERE topic_id='$topic_id' order by post_id DESC";
$query2 = "select * from forum_inhoud WHERE topic_id='$topic_id' order by post_id DESC";
//Query's uitvoeren
$result1 = mysql_query($query2, $dbc) or die (mysql_error ());
$result2 = mysql_query($query2, $dbc) or die (mysql_error ());
$row1 = mysql_fetch_array($result1);
$topic_name = $row1['parent2']
?>
error_reporting(E_ALL);
if ($_SESSION['user_ID'] == "")
{
print("<div align=\"center\"><span class=\"xbig\">Je bent niet ingelogd!</span><br /> <br /><span class=\"style4\"><a href=\"/paginas/login.php\">Hier</a> kun je je inloggen</span></div>");
exit;
}
//Informatie uit GET halen.
$topic_id = $_GET['topic_id'];
//verbinding maken met da database!
$dbc = mysql_connect('localhost', '****', '******´);
mysql_select_db('knorfski', $dbc);
//Query's aanmaken
$query1 = "select * from forum_inhoud WHERE topic_id='$topic_id' order by post_id DESC";
$query2 = "select * from forum_inhoud WHERE topic_id='$topic_id' order by post_id DESC";
//Query's uitvoeren
$result1 = mysql_query($query2, $dbc) or die (mysql_error ());
$result2 = mysql_query($query2, $dbc) or die (mysql_error ());
$row1 = mysql_fetch_array($result1);
$topic_name = $row1['parent2']
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<style type="text/css">
<!--
.style7 {
font-size: 10px;
font-style: italic;
}
.style8 {
font-size: 16px;
font-weight: bold;
}
.style10 {font-size: 16px}
.style11 {
font-size: 12px;
font-style: italic;
}
-->
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Topic</title>
</head>
<body>
<div align="center">
<p><span class="style6 style8"><span class="style6 style10">Topic: <em><br />
</em></span></span>
</p>
<table width="800" border="1">
<tr>
<td width="200" border="1">
<div align="center"><em>Gepost door: </em><strong><br />
</strong></div></td>
<td height="22"><div align="center" class="style4">
<p align="center"><span class="style11">Bericht:</span><br />
</p>
</div></td>
</tr>
</table>
<table width="800">
<tr>
<td>
<div align="center" class="style7">Gepost op: </div> </td>
</tr>
</table>
<p><br />
<br />
</p>
<table width="385" border="1">
<tr>
<td><form id="form1" name="form1" method="post" action="/paginas/forum/handlers/handle_postreply.php?topic_id=">
<div align="center">
<p class="style4"><strong>Reply:</strong></p>
<p>
<textarea name="reply" rows="8" cols="60"></textarea>
</p>
</div>
<p align="center">
<label></label>
<input type="submit" name="Submit" value="Post reply!" />
</p>
</form>
</td>
</tr>
</table>
<p> <br />
<br />
</p>
</div>
</body>
</html>
</div>
De normale manier is:
1) query maken
2) query uitvoeren
3) op de plek waar je wilt echoën een while lus zetten met fetch-functie
Code (php)
1
2
3
4
5
2
3
4
5
<?php
while ($row = mysql_fetch_array ($res)) {
echo '<p>'.$row['veldnaam'].'</p>';
}
?>
while ($row = mysql_fetch_array ($res)) {
echo '<p>'.$row['veldnaam'].'</p>';
}
?>
dan krijg ik gewoon de regels aanelkaar geplakt.
Als ik de html <br/> erin doe dan pakt hij wel de volgende regel!
Iemand de oplossing voor mij?