PHP1989 Posted June 15, 2007 Share Posted June 15, 2007 I am trying to call information from a MySQL database in for form of an editable form. I want the info to be called into a box that can by typed in and so far that works. What I want to do next is to be able to change what is in those boxes and click an update button which updates what was called from the database to what I typed in the box. The code I wrote is below and almost works. I'm not sure what the problem is. Any help at all is much appreciated. Thank you! <?php include("config.php"); print "<table width=97% border=0> <tr> <th scope=row><A href=actionid.php?a=id>Id</a></th> <th><A href=actionid.php?a=name>Name</a></th> <th>Info</th> <th>Url</th> <th><A href=actionid.php?a=type>Type</a></th> <th><A href=actionid.php?a=mobid>Mobid</a></th> <th>Ops</th> </tr>"; $color1 = "#91ada8"; $color2 = "#688b85"; $row_count = 0; if ($a == ''){ $a = "id"; } $wsel = mysql_query("select * from actionid where id=$did"); while ($action = mysql_fetch_array($wsel)) { if ($action[type] == 1) { $tipe = "Monster";} if ($action[type] == 2) { $tipe = "House"; } if ($action[type] == 3) { $tipe = "Chest"; } if ($action[type] == 4) { $tipe = "Sign"; } $row_color = ($row_count % 2) ? $color1 : $color2; print "<tr BGCOLOR=$row_color> <td scope=row><A href=actionid.php?$query&page=info&info=$action[id]></a><input type=number name=info value=$action[id]></td> <td><input type=number name=name value=\"$action[name]\"></td> <td><input type=number name=info value=\"$action[info]\"></td> <td><input type=number name=url value=\"$action[url]\"></td> <td>$tipe<input type=number name=type value=$action[type]></td> <td><input type=number name=mobid value=$action[mobid]></td> <td><A href=actionidedit.php?view=edit&did=$action[id]&step=upd&id=$did>Update</a></td> </tr>"; $row_count++; } if($step == upd){ mysql_query("UPDATE `actionid` SET `name` =$name, `info` = '$info', `url` = '$url', `type` = '$type', `mobid` = '$mobid' WHERE `id` = '$did'"); print "You updated ID $did<br>"; print "updated $did to $name<br>"; print "updated $did to $info<br>"; print "updated $did to $url<br>"; print "updated $did to $type<br>"; print "updated $did to $mobid"; } print "</table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/55656-form-editing/ Share on other sites More sharing options...
btherl Posted June 15, 2007 Share Posted June 15, 2007 What happens when you click the update button? Quote Link to comment https://forums.phpfreaks.com/topic/55656-form-editing/#findComment-275069 Share on other sites More sharing options...
atomicrabbit Posted June 15, 2007 Share Posted June 15, 2007 yeah, we need to know what the problem is before we can help you figure out the solution. Quote Link to comment https://forums.phpfreaks.com/topic/55656-form-editing/#findComment-275112 Share on other sites More sharing options...
Neptunus Maris Posted June 15, 2007 Share Posted June 15, 2007 I dont see the following tags in the script that need to be there: <form></form> that needs to be there in the script in order to submit things and retrieve variable values in the input field. <form action = \"$_SERVER[php_SELF]\" method = \"post\"> //... </form> use that if you are submitting to the same page...which it looks like you are doing. Quote Link to comment https://forums.phpfreaks.com/topic/55656-form-editing/#findComment-275114 Share on other sites More sharing options...
PHP1989 Posted June 15, 2007 Author Share Posted June 15, 2007 When I click update it makes all the fields blank. It resets all the values to nothing. Quote Link to comment https://forums.phpfreaks.com/topic/55656-form-editing/#findComment-275383 Share on other sites More sharing options...
btherl Posted June 19, 2007 Share Posted June 19, 2007 I think you need to use a form rather than an href. An href will not pass on any information in input tags. Quote Link to comment https://forums.phpfreaks.com/topic/55656-form-editing/#findComment-277440 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.