Okay, her er så mine to filer:
rediger.php
<?
include('database.php');
$hent = mysql_query("SELECT * FROM nyhed ORDER BY id DESC") or die(mysql_error());
if(mysql_num_rows($hent)) {
while($vis = mysql_fetch_array($hent)) {
?>
<? echo $vis['overskrift']; ?> - <a href="rediger_vis.php?id=<? echo $vis['id']; ?>">Rediger!</a><br>
<?
}
} else {
echo("Ingen nyheder!");
}
?>
<html>
<head>
</head>
<link href="../index.css" rel="stylesheet" type="text/css">
<body oncontextmenu="return false" ondragstart="return false" onselectstart="return false">
</body>
</html>
og min rediger_vis.php
<?
include('database.php');
if($_GET['id'] != "") {
if($_GET['update'] == 1) {
mysql_query("UPDATE nyhed SET navn = ".$_POST['navn'].", overskrift = ".$_POST['overskrift'].", besked = ".$_POST['besked']." WHERE id = ".$_GET['id']) or die(mysql_error());
}
$hent = mysql_query("SELECT * FROM nyhed ORDER BY id DESC") or die(mysql_error());
if(mysql_num_rows($hent)) {
while($vis = mysql_fetch_array($hent)) {
?>
<html>
<head>
</head>
<link href="../index.css" rel="stylesheet" type="text/css">
<body>
<form action=rediger_vis.php?id="<? $_GET['id']; ?>"&update=1 method=post>
<b>Navn:</b><br>
<input type="text" name="navn" size="15" value="<? echo $vis['navn']; ?>"><br>
<b>Overskrift:</b><br>
<input type="text" name="overskrift" size="15" value="<? echo $vis['overskrift']; ?>"><br>
<b>Nyhed:</b><br>
<textarea rows="15" cols="70" name="besked"><? echo $vis['besked']; ?></textarea><br>
<input type="submit" name="submit" value="Skriv" >
<input type="reset" name="delete" value="Tøm felter" >
</form>
</body>
</html>
<?
}
}
}
?>
Men der er stadig fejl, den siger:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Design!, besked = Jaah, så er der kommet nyt design igen, jeg blForstår det ikke, lidt hjælp?
____________________________
PHP is just to good to be true