williamh69 Posted May 7, 2014 Share Posted May 7, 2014 hi guys i cant edit my data... what is my error <?php // get value of id that sent from address bar $menu_id=$_GET['menu_id']; // Retrieve data from database $sql="SELECT * FROM menus WHERE menu_id='$menu_id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result) ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <form name="form1" method="post" action="update_ac.php"> <td> <table width="100%" border="0" cellspacing="1" cellpadding="0"> <tr> <td> </td> <td colspan="3"><strong>Update data in mysql</strong> </td> </tr> <tr> <td align="center"> </td> <td align="center"> </td> <td align="center"> </td> <td align="center"> </td> </tr> <tr> <td align="center"> </td> <td align="center"><strong>Menu name</strong></td> </tr> <tr> <td> </td> <td align="center"> <input name="menu_name" type="text" id="menu_name" value="<? echo $rows['menu_name']; ?>"> </td> <td> </td> <td align="center"> <input type="submit" name="Submit" value="Submit"> </td> <td> </td> </tr> </table> </td> </form> </tr> </table> <?php // close connection mysql_close(); ?> error said:_ notice: Undefined index: menu_id in C:\wamp\www\sparklenshine2\admin\edit.inc.php on line 4 the tablet is: menu_id | menu_name Quote Link to comment Share on other sites More sharing options...
trq Posted May 7, 2014 Share Posted May 7, 2014 $_GET['menu_id'] will not exist until your form is submitted. So.. wrap all the php code at the top of your script in a condition that checks to see if the form has been submitted. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.