Jump to content

How can I do an update on the inside of the fields that display data?


ahmedarkan

Recommended Posts

Hello


I have the data in the database for a client appear in the fields of input type = text ... Is it possible modification or replacement of the data within the fields to anything I want to do by the submit button replaces the data that I have typed the previous allowance in the database table? And how?

I want exactly similar way when the edit data in phpmyadmin.

like this :

 

foratweb-7c3571c997.jpg

 

foratweb-7bfedd1c19.jpg
 

This review of the data code ... I want to make the update button on this page.


$name = addslashes($_POST['dname']);

$con=mysqli_connect("localhost","root","","ahmedark_depot");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$result = mysqli_query($con,"SELECT * FROM driver_info WHERE driver_name ='$name'");


while($row = mysqli_fetch_array($result))
  {
    echo "drivername: <input type=\"text\" name=\"id\" value = \"$row[id]\"><br /><br />" ;
    echo "drivername: <input type=\"text\" name=\"driver_name\" value = \"$row[driver_name]\"><br /><br />" ;
    echo "prevent: <input type=\"text\" name = \"prevent\" value = \"$row[prevent]\"><br /><br />" ;
    echo "note prev: <input type=\"text\" name = \"note_prev\" value = \"$row[note_prev]\"><br /><br />" ;
    echo "note : <input type=\"text\" name = \"general_note\" value = \"$row[general_note]\"><br /><br />" ; 
         
  }


mysqli_close($con);



?>
Edited by ahmedarkan
Link to comment
Share on other sites

Hello

 

 

I have the data in the database for a client appear in the fields of input type = text ... Is it possible modification or replacement of the data within the fields to anything I want to do by the submit button replaces the data that I have typed the previous allowance in the database table? And how?

 

I want exactly similar way when the edit data in phpmyadmin.

like this :

 

This review of the data code ... I want to make the update button on this page.

$name = addslashes($_POST['dname']);

$con=mysqli_connect("localhost","root","","ahmedark_depot");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$result = mysqli_query($con,"SELECT * FROM driver_info WHERE driver_name ='$name'");


while($row = mysqli_fetch_array($result))
  {
    echo "drivername: <input type=\"text\" name=\"id\" value = \"$row[id]\"><br /><br />" ;
    echo "drivername: <input type=\"text\" name=\"driver_name\" value = \"$row[driver_name]\"><br /><br />" ;
    echo "prevent: <input type=\"text\" name = \"prevent\" value = \"$row[prevent]\"><br /><br />" ;
    echo "note prev: <input type=\"text\" name = \"note_prev\" value = \"$row[note_prev]\"><br /><br />" ;
    echo "note : <input type=\"text\" name = \"general_note\" value = \"$row[general_note]\"><br /><br />" ; 
         
  }


mysqli_close($con);



?>

 

If I'm understanding correctly, you want to make your output into an HTML form which can be submitted and make changes in the data.  If you cannot use PHPMyAdmin to do this (I'm presuming because you do not wish for WWW users to have access to PHPMyAdmin  ;D  ;D ), then you'll first need to modify your output to have "<form>" tags (which may have already been done, you do seem to have <input> tags), and then write a handler for the POSTed data.

 

For a basic button, you need this:

 

<input type='submit'>
You must make sure the form has a "method" attribute of "post" and an action attribute that points to your handler script:
<form method="post" action="myhandler.php">
You can see what is in the post array like this:

 

print_r($_POST);
Edited by dalecosp
Link to comment
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.