Nieuw lid |
|
<?
require("connection.php");
//If cmd has not been initialized
if(!isset($cmd))
{
//display all the paintings
$result = mysql_query("select * from kleurplaten order by id");
//run the while loop that grabs all the paintings
while($r=mysql_fetch_array($result))
{
//grab the title and the ID of the paintings
$titel=$r["titel"];//take out the title
$id=$r["id"];//take out the id
//make the title a link
echo "<a href='editkleurplaten.php?cmd=edit&id=$id'>Edit - $titel</a>";
echo "<br>";
}
}
?>
<?
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
{
if (!isset($_POST["submit"]))
{
$id = $_GET["id"];
$sql = "SELECT * FROM kleurplaten WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form action="editkleurplaten.php" method="post">
<p>
<input type=hidden name="id" value="<?php echo $myrow["id"] ?>">
Titel:
<INPUT TYPE="TEXT" NAME="titel" VALUE="<?php echo $myrow["titel"] ?>" SIZE=30>
<br>
<br>
Link_klein:
<INPUT TYPE="TEXT" NAME="link_klein" VALUE="<?php echo $myrow["link_klein"] ?>" SIZE=30>
</p>
<p>Link_groot:
<INPUT TYPE="TEXT" NAME="link_groot" VALUE="<?php echo $myrow["link_groot"] ?>" SIZE=30>
</p>
<p>id:
<INPUT NAME="id" TYPE="TEXT" id="id" VALUE="<?php echo $myrow["id"] ?>" SIZE=30>
<br>
<input type="hidden" name="cmd" value="edit">
<input type="submit" name="submit" value="submit">
</p>
</form>
<? } ?>
<?
if ($_POST["submit"])
{
$titel = $_POST["titel"];
$link_klein = $_POST["link_klein"];
$link_groot = $_POST["link_groot"];
$sql = "UPDATE kleurplaten SET titel='$titel',link_klein='$link_klein',link_groot='$link_groot' WHERE id=$id";
$result = mysql_query($sql);
echo "Bijgewerkt!";
}
}
?>
<? require("connection.php"); //If cmd has not been initialized { //display all the paintings $result = mysql_query("select * from kleurplaten order by id"); //run the while loop that grabs all the paintings { //grab the title and the ID of the paintings $titel=$r["titel"];//take out the title $id=$r["id"];//take out the id //make the title a link echo "<a href='editkleurplaten.php?cmd=edit&id=$id'>Edit - $titel</a>"; } } ?> <? if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit") { if (!isset($_POST["submit"])) { $id = $_GET["id"]; $sql = "SELECT * FROM kleurplaten WHERE id=$id"; ?> <form action="editkleurplaten.php" method="post"> <p> <input type=hidden name="id" value=" <?php echo $myrow["id"] ?>"> Titel: <INPUT TYPE="TEXT" NAME="titel" VALUE=" <?php echo $myrow["titel"] ?>" SIZE=30> <br> <br> Link_klein: <INPUT TYPE="TEXT" NAME="link_klein" VALUE=" <?php echo $myrow["link_klein"] ?>" SIZE=30> </p> <p>Link_groot: <INPUT TYPE="TEXT" NAME="link_groot" VALUE=" <?php echo $myrow["link_groot"] ?>" SIZE=30> </p> <p>id: <INPUT NAME="id" TYPE="TEXT" id="id" VALUE=" <?php echo $myrow["id"] ?>" SIZE=30> <br> <input type="hidden" name="cmd" value="edit"> <input type="submit" name="submit" value="submit"> </p> </form> <? } ?> <? if ($_POST["submit"]) { $titel = $_POST["titel"]; $link_klein = $_POST["link_klein"]; $link_groot = $_POST["link_groot"]; $sql = "UPDATE kleurplaten SET titel='$titel',link_klein='$link_klein',link_groot='$link_groot' WHERE id=$id"; } } ?>
Ik heb een tabel "kleurplaten". Alles wordt netjes uitgelezen en op id gesorteerd. Maar als ik iets wil bijwerken dan pakt hij de verkeerde id nummer. De melding "Bijgewerkt" komt wel! Maar hij veranderd namelijk elke keer de laatste die in de database staat en niet die hij moet veranderen.
|