avraamG13 Posted May 3, 2009 Share Posted May 3, 2009 Hello, i really need your help on this... Im building an update field form but i cant make it work and alwaying (after googleing.. and trying new codes) getting any error you can image of.. Anyone can make the changes for me? and also explaing me what im doing wrong so i will learn some thinks?? P.S Aso to show me how i can make it not to post if the update data is empty and 'sort_order' row is not numbers (1-99 is the limit) <? if(isset($_GET['edit'])) { $name = $_POST["name"]; $remarks = $_POST["remarks"]; $sort_order = $_POST["sort_order"]; //$query = "SELECT * FROM players_category WHERE news_id = id = '{$_GET['edit']}'"; $query = "SELECT * FROM players_category WHERE id = '{$_GET['edit']}'"; $result = mysql_query($query); $myrow = mysql_fetch_array($result); } ?> <? if(isset($_GET['Submit'])) { $name = $_POST["name"]; $remarks = $_POST["remarks"]; $sort_order = $_POST["sort_order"]; $result = mysql_query($query); $query = "UPDATE players_category SET name = '$name', remarks = '$remarks', sort_order = '$sort_order' WHERE id=$id"; } ?> <form name="Update" method="post" action=""> <table id="Update" style="width: 100%"> <tr> <td colspan="2" class="titlebarmain"><strong>Edit Selection</strong></td> </tr> <tr> <td style="width: 91px">Name: </td> <td> <input name="name0" maxlength="30" size="30" type="text" value="<?php echo $myrow["name"] ?>" class='textbox'> (max. 30 characters)</td> </tr> <tr> <td style="width: 91px">Remarks:</td> <td> <input name="remarks0" maxlength="120" size="30" value="<?php echo $myrow["remarks"] ?>" type="text" class='textbox'> (max. 120 characters)</td> </tr> <tr> <td style="width: 91px">Sorting:</td> <td> <input name="sort_order0" maxlength="2" size="30" value="<?php echo $myrow["sort_order"] ?>" type="text" class='textbox'> (1-99)</td> </tr> <tr> <td style="width: 91px"> </td> <td> <input type="submit" name="submit" value="Update" class='button' ></td> </tr> </form> </table> Thank you Link to comment https://forums.phpfreaks.com/topic/156649-solved-update-field-form-errors-need-help/ Share on other sites More sharing options...
gevans Posted May 3, 2009 Share Posted May 3, 2009 $query = "UPDATE players_category SET name = '$name', remarks = '$remarks', sort_order = '$sort_order' WHERE id=$id"; That line doesn't go through mysql_query($query); The following lines need to be swapped around; $result = mysql_query($query); $query = "UPDATE players_category SET name = '$name', remarks = '$remarks', sort_order = '$sort_order' WHERE id=$id"; Link to comment https://forums.phpfreaks.com/topic/156649-solved-update-field-form-errors-need-help/#findComment-824828 Share on other sites More sharing options...
avraamG13 Posted May 3, 2009 Author Share Posted May 3, 2009 i dident understant what i have to change . Can you show me an example of what you mean please? Thank you Link to comment https://forums.phpfreaks.com/topic/156649-solved-update-field-form-errors-need-help/#findComment-824847 Share on other sites More sharing options...
gevans Posted May 3, 2009 Share Posted May 3, 2009 The following lines need to be swapped around; $result = mysql_query($query); $query = "UPDATE players_category SET name = '$name', remarks = '$remarks', sort_order = '$sort_order' WHERE id=$id"; $query = "UPDATE players_category SET name = '$name', remarks = '$remarks', sort_order = '$sort_order' WHERE id=$id"; $result = mysql_query($query); Link to comment https://forums.phpfreaks.com/topic/156649-solved-update-field-form-errors-need-help/#findComment-824848 Share on other sites More sharing options...
avraamG13 Posted May 3, 2009 Author Share Posted May 3, 2009 Still nothing.. i dont know maybe im doing something wrong in my form or something? Link to comment https://forums.phpfreaks.com/topic/156649-solved-update-field-form-errors-need-help/#findComment-824853 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.