erik026 Posted July 8, 2009 Share Posted July 8, 2009 Hi everybody, I'm bizzy with this assignment for scool. I haven´t got very much experience, so i've got a question. I'm making a startpage were i can add, remove and change links. Add and removing links works. I want to change the links by using a checkbox. If the id of the link is checked, then people can fill in the new link, linkname or categorie by using a textbox. This is the code i have now, i don't get an error, but it doesn't work. This is my code. <link href="css.css" rel="stylesheet" type="text/css" /><br> <?PHP error_reporting(E_ALL); include_once("config.php"); if(isset($_POST['delete'])) { $id = $_POST['id']; $delete = "DELETE FROM voetbal WHERE id='$id'"; $query = mysql_query($delete) or die (mysql_error());?> <p class="link">Deze link is verwijderd.<meta http-equiv="Refresh" content="2; url=http://localhost/index.php"><? } elseif (isset($_POST['wijzig'])) { $id = $_POST['id']; $nieuweurl = $_POST['nieuweurl']; $nieuwecategorie = $_POST['nieuwecategorie']; $nieuwelinknaam = $_POST['nieuwelinknaam']; //$url = $_POST['url']; //$categorie = $_POST['categorie']; //$linknaam = $_POST['linknaam']; $wijzig = "UPDATE voetbal SET url = '['$nieuweurl']', linknaam = '['$nieuwelinknaam']', categorie = '['$nieuwecategorie']' WHERE id ='['$id']'"; $query = mysql_query($wijzig) or die (mysql_error()); } ?> <form name="approve" action="" method="post"> <table class="selectTABLE" align="center" bgcolor="#FFFFFF"> <tr> <td colspan="6" class="formtitleTD"> <p class="link">Links verwijderen en wijzigen. </td> </tr> <tr> <td> </td> <td class="selectidTD"> <p class="link">ID </td> <td class="selectlinknameTD"> <p class="link">Link naam </td> <td class="selectlinkTD"> <p class="link">URL </td> <td class="selectcategorieTD"> <p class="link">Categorie </td> </tr> <?PHP include_once("config.php"); $sql = mysql_query("SELECT * FROM voetbal ORDER BY id"); while($result = mysql_fetch_array($sql)) { echo "<tr> <td><input type='checkbox' name='id' value='".$result['id']."' class='inputcheckbox'></td> <td>".$result['id']."</td> <td>".$result['linknaam']."</td> <td>".$result['url']."</td> <td>".$result['categorie']."</td> </tr> <tr> <td></td> <td><input type='text' name='id' size='25' class='textvak'></td> <td><input type='text' name='nieuwelinknaam' size='25' class='textvak'></td> <td><input type='text' name='nieuweurl' size='25' class='textvak'></td> <td><input type='text' name='nieuwecategorie' size='25' class='textvak'></td> </tr>"; } ?> <tr> <td colspan="6" align="right"> <input type="submit" name="delete" value="delete" class="inputbutton"> </td> <td colspan="6" align="right"> <input type="submit" name="wijzig" value="wijzig" class="inputbutton"> </td> </tr> <tr> <td><a href="index.php"><p class="link">Terug</a> </td> </tr> </table> </form> Thanks a lot, Erik Link to comment https://forums.phpfreaks.com/topic/165262-update-statement-withvariable/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.