I’m trying to select the table gaestebog inside the database akron11_db, and i dont know what the command is, the table has 3 values, id, bruger, and besked (id,user,message).
Second problem is that the <?php tag at the bottom wont close after the table is created.
I’m using notepad++ so i can see the tag is not closed due to the color coding.
Thanks in advance, i hope to one day be the guru in here that can help all you others.
<!DOCTYPE html>
<html>
<?php
$sql = mysql_connect("localhost", "USER", "PW") or die(mysql_error);
mysql_select_db("akron11_db", $sql);
if($_SERVER ['REQUEST_METHOD'] == 'POST')
{
$bruger = mysql_real_escape_string($_POST)['bruger']);
$besked = mysql_real_escape_string($_POST['besked']);
$query = mysql_query("INSERT INTO message (bruger,besked) VALUES ('$bruger, $besked)");
echo ("Tak for beskeden")
}
?>
<form action="index.php" method="post">
User: <input type="text" name="bruger"/><br />
Message <textarea name="besked"></textarea>
<input type="submit" value="post!"/>
</form>
<?php
$result = mysql_query ("SELECT * FROM besked ORDER BY id DESC");
//DESC er decending
while($row = mysql_fetch_array($result));
{
<table>
<tr>
<td>Bruger:</td>
<td><?php echo $row['bruger'] ?></td>
</tr>
<tr>
<td>Besked:</td>
<td><?php echo $row['besked'] ?></td>
</tr>
</table>
<hr />
}
?>
</html>
You need opening and closing PHP tags around the HTML snippet: