Jump to content

Recommended Posts

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>";




?>

Link to comment
https://forums.phpfreaks.com/topic/55656-form-editing/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/55656-form-editing/#findComment-275114
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.