Jeremygolf
Mitglied
Wiso funktioniert das UPDATE nicht?
lg Jeremygolf
lg Jeremygolf
Code:
<?php
if ($_POST['titel'] != ""){
include_once('connect_to_mysql.php');
$id = $_POST["id"];
$titel = $_POST["titel"];
$text = $_POST["text"];
$bild = $_POST["bild"];
$numRows = mysql_num_rows($sql);
$sql = mysql_query("UPDATE `andrea`.`news` SET `titel` = '$titel', `bild` = '$bild',
`text` = '$text' WHERE `news`.`id` ='$id';");
}
?>
<?php
include_once('connect_to_mysql.php');
$id = (int)$_GET["id"];
$sql = mysql_query("SET NAMES 'utf8'");
$sql = mysql_query("SELECT * FROM `news` WHERE id = $id");
while($row = mysql_fetch_array($sql))
{
$id = $row["id"];
$date = $row["date"];
$titel = $row["titel"];
$text = $row["text"];
$bild = $row["bild"];
}
?>
<?php
session_start();
if (isset($_SESSION["username"])) {
?>
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div id="mainpage">
<div id="navigation"><ul id="navi">
<?php include("php/navi.php"); ?>
</ul>
</div>
<div id="content">
<h1>News</h1>
<p>Hier kannst du deine News bearbeiten</p>
<form action="news_bearbeiten.php?id=<?php echo $id; ?>" method="post">
<?php echo $msg_to_user; ?>
Titel: <br /> <input name="titel" type="text" value="<?php echo $titel; ?>" /><br />
Bild: <br /> <input name="bild" type="text" value="<?php echo $bild; ?>" /><br />
Bild: <br /> <input style="border: none;" name="bild" type="file" value="<?php echo $bild; ?>" /><br />
Text: <br /> <textarea name="text" cols="50" rows="20" value="<?php echo $text; ?>"><?php echo $text; ?></textarea><br />
<input class="button" name="submit" type="submit" value="Publizieren" />
</form>
</div>
</div>
</body>
</html>
<?php
} else {
?>
Bitte erst einlogen, <a href="index.php">hier</a>.
<?php
}
?>