PHP gevorderde |
|
Dit is het php script waarmee ik de bestanden in de tekst velden zet
<?php
require_once('connect.php');
$query = "SELECT * FROM gastenboek ORDER BY id DESC";
$sql=mysql_query($query) or die (mysql_error());
while ($obj=mysql_fetch_object($sql)) {
$id = $obj->id;
$door = $obj->door;
$datum = $obj->datum;
$email = $obj->email;
$bericht = $obj->bericht;
?>
<table>
<form action="edit.php" method="post">
<tr>
<th>ID: </th>
<td><input type="text" name="id" value="<?php echo $id; ?>" size="25" /></td>
</tr>
<tr>
<th>Naam: </th>
<td><input type="text" name="door" value="<?php echo $door; ?>" size="25" /></td>
<tr>
<th>Datum: </th>
<td><input type="text" name="datum" value="<?php echo $datum ?>" size="25" /></td>
</tr>
<tr>
<th>Email: </th>
<td><input type="text" name="email" value="<?php echo $email ?>" size="25" /></td>
</tr>
<tr>
<th>Bericht: </th>
<td><textarea cols="25" rows="7" wrap="VIRTUAL"><?php echo $bericht; ?></textarea></td>
</tr>
<tr>
<th colspan="2"><input name="submit" type="submit" id="submit" value="Edit" /></th>
</tr>
</form>
</table><br />
<?php } ?>
<?php require_once('connect.php'); $query = "SELECT * FROM gastenboek ORDER BY id DESC"; $id = $obj->id; $door = $obj->door; $datum = $obj->datum; $email = $obj->email; $bericht = $obj->bericht; ?> <table> <form action="edit.php" method="post"> <tr> <th>ID: </th> <td><input type="text" name="id" value=" <?php echo $id; ?>" size="25" /></td> </tr> <tr> <th>Naam: </th> <td><input type="text" name="door" value=" <?php echo $door; ?>" size="25" /></td> <tr> <th>Datum: </th> <td><input type="text" name="datum" value=" <?php echo $datum ?>" size="25" /></td> </tr> <tr> <th>Email: </th> <td><input type="text" name="email" value=" <?php echo $email ?>" size="25" /></td> </tr> <tr> <th>Bericht: </th> <td><textarea cols="25" rows="7" wrap="VIRTUAL"> <?php echo $bericht; ?></textarea></td> </tr> <tr> <th colspan="2"><input name="submit" type="submit" id="submit" value="Edit" /></th> </tr> </form> </table><br /> <?php } ?>
En dit is mijn script waarmee ik de bestanden wil Update
<?php
require_once('connect.php');
$id=$_POST['id'];
$door=$_POST['door'];
$datum=$_POST['datum'];
$email=$_POST['email'];
$bericht=$_POST['bericht'];
if($_POST['submit'])
{
mysql_query("UPDATE gastenboek SET door='$door' email='$email' datum='$datum' bericht='$bericht' WHERE='$id'");
echo("Gelukt");
}
else
{
echo("MISLUKT");
}
?>
<?php require_once('connect.php'); $id=$_POST['id']; $door=$_POST['door']; $datum=$_POST['datum']; $email=$_POST['email']; $bericht=$_POST['bericht']; if($_POST['submit']) { mysql_query("UPDATE gastenboek SET door='$door' email='$email' datum='$datum' bericht='$bericht' WHERE='$id'"); } else { } ?>
die echo heb ik er bij gezet voor mij het gemakkelijk te maken.
|