I have a form and successfully connect them to the database.
Now I'm trying to update the data. Unfortunately, nothing happened when I click the submit button. I'm sure I miss something. Please help me, thank you.
config.php :
<?php
$conn=odbc_connect("dsn", "", "");
if (!$conn)
{
exit("Connection Failed : " . $conn);
}
?>
This is my code :
<?php
include "config.php";
ini_set('error_reporting', E_ALL);
error_reporting(-1);
$sql = odbc_exec( $conn, "SELECT
UserId,
UserName,
UserEmail
FROM DBA.tblUser
WHERE UserId='".$_GET['UserId']."'");
if(isset($_POST['submit']))
{
$UserId=$_POST["UserId"];
$UserName=$_POST["UserName"];
$UserEmail=$_POST["UserEmail"];
//UPDATE
$stmt = odbc_exec( $conn,
"UPDATE DBA.tableUsers SET
UserName = '$UserName',
UserEmail ='$UserEmail'
WHERE UserId=$UserId");
if ($stmt) {
echo "Update Success";
echo $UserName;
echo $UserEmail;
} else {
"Error : " . odbc_errormsg();
}
}
?>
Form :
<form class="form" method="post">
<tr>
<td class = "userid">User ID</td>
<td><?php echo $UserId = odbc_result($sql,'UserId'); ?></td>
</tr>
<tr>
<td class = "name">User Name<span class="required"> * </span></td>
<td><input type="text" name="UserName" value="<?php echo $UserName = odbc_result($sql,'UserName'); ?>"></td>
</tr>
<tr>
<td class = "email">Email<span class="required"> * </span></td>
<td><input type="text" name="UserEmail" value="<?php echo $UserEmail = odbc_result($sql,'UserEmail'); ?>"></td>
</tr>
<button name="submit" type="submit" value ="submit" >Update</button>
</form>
Replace
$UserName=$_POST["UserName"];
With
$UserName=$_POST["UserId"];
Why? Simply because in your form, you have name as UserId and not UserName
<input type="text" name="UserId" value="<?php echo $UserName = odbc_result($sql,'UserName'); ?>"></td>
I managed to get the answer with the same concept and variable.
config.php :
<?php
$conn=odbc_connect("dsn", "", "");
if ($conn) {
echo "Connected";
}
if (!$conn) {
exit("Connection Failed : " . $conn);
}
?>
code :
<?php
include "config.php";
$sql = odbc_exec( $conn, "SELECT
UserId,
UserName,
UserEmail
FROM DBA.tblUser
WHERE UserId='".$_GET['UserId']."'");
if(isset($_POST['submit'])) {
$UserName=$_POST["UserName"];
$UserEmail=$_POST["UserEmail"];
$stmt = odbc_exec($conn,
"UPDATE DBA.tblUser SET
UserName = '$UserName',
UserEmail ='$UserEmail'
WHERE UserId='".$_GET['UserId']."'");
if ($stmt) {
echo "Update Successfull";
echo $UserName;
echo $UserEmail;
}
else {
"Error : " . odbc_errormsg();
}
}
?>
html :
<!DOCTYPE html>
<html>
<head>
<title>Administration</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="css/userpage.css" media="screen"/>
<body>
<content>
<div class="user-form">
<div class="user-form-heading">Update User</div><br>
<form class="form" method="post">
<h><table class ="user">
<!-- .................................. Updatable ....................................... -->
<tr>
<td class = "name">User Name<span class="required"> * </span></td>
<td><input type="text" name="UserName" value="<?php echo $UserName = odbc_result($sql,'UserName'); ?>"></td>
</tr>
<tr>
<td class = "userid">User Id</td>
<td><?php echo $UserId = odbc_result($sql,'UserId'); ?></td>
</tr>
<tr>
<td class = "email">Email<span class="required"> * </span></td>
<td><input type="text" name="UserEmail" value="<?php echo $UserEmail = odbc_result($sql,'UserEmail'); ?>"></td>
</tr>
<tr>
<td>
<f><button name="submit" type="submit" value ="submit" >UPDATE</button></f>
</table>
</form>
</div>
</content>
</body>
</head>
</html>
Related
I have created a php sticky form so data will not disappear when the submit button is clicked. A url link is being used to pass values to a form so they can be edited. However, the values from the url are not being passed into the form fields. Why are the values from the url not being passed into the form fields? Thank you so much for your time.
This is the code:
index.php
<?php
require_once('authorize.php');
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<?php
require_once('appvars.php');
require_once('connectvars.php');
$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$data = mysqli_query($conn, $query);
echo '<table>';
echo '<tr><th>Name</th><th>Caption</th><th>Action</th></tr>';
while ($row = mysqli_fetch_array($data)) {
//link
echo '<td><a href="link.php?id=' . $row['id'] . '&image=' . $row['image1'] . '&name=' . $row['name'] .
'&caption=' . $row['caption'] .
'&video=' . $row['video'] . '">Edit </a>';
echo '</td></tr>';
}
echo '</table>';
echo "<br><br>";
mysqli_close($conn);
?>
</body>
</html>
sticky_form.php
<!DOCTYPE html>
<html>
<head>
<title>Edit Conent</title>
</head>
<body>
<h3>Edit Conent</h3>
<?php
require_once('appvars.php');
require_once('connectvars.php');
$vid="";
$vname="";
$vcaption="";
$vvideo="";
$id ="";
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if(isset($_POST["button_edit"])){
$id = $_POST["id"];
$name = $_POST['name'];
$caption = $_POST['caption'];
$video = $_POST['video'];
$qry = mysqli_query($dbc,"Update table1 Set name='$name', caption='$caption', video='$video' Where id='$id'");
else if(isset($_GET["id"])){
$qry = mysqli_query($dbc,"Select * From table1 Where id='".$_GET["id"]."'");
while($row=mysqli_fetch_array($qry,MYSQLI_ASSOC)){
$vid=$row["id"];
$vname=$row["name"];
$vcaption=$row["caption"];
$vvideo=$row["video"];
}
}
?>
<body>
<form action='' method="post" enctype="multipart/form-data" >
<table>
<tr>
<td>ID</td>
<td><input type="text" name="id" value="<?php echo $vid;?>"></td></tr>
<tr>
<td>Name</td>
<td><input type="text" class="bigger_textbox" name="name" value="<?php if (isset($_POST['name'])) {echo htmlentities($_POST['name']);}?>"></td></tr>
<tr><td>Caption</td>
<td><input type="text" class="bigger_textbox" name="caption" value="<?php if (isset($_POST['caption'])) {echo htmlentities($_POST['caption']);}?>"></td></tr>
<tr><td>Video</td>
<td><input type="text" class="bigger_textbox" name="video" value="<?php if (isset($_POST['video'])) {echo htmlentities($_POST['video']);}?>"></td></tr>
<tr><td colspan="2">
<input type="submit" name="button_edit" value="Edit Content"></td></tr> </table>
</form>
<table border=1>
<tr><th>Name</th><th>Caption</th>
<th>Video</th> <th>Action</th></tr>
<?php
if (isset($_GET["id"])) {
$qry =mysqli_query($dbc, "Select * From table1 Where id='".$_GET["id"]."'");
while($row=mysqli_fetch_array($qry,MYSQLI_ASSOC)) {
echo '<tr><td>'.$row["name"].'</td>';
echo '<td>'.$row["caption"].'</td>';
echo '<td>'.$row["video"].'</td>';
echo '<td>Edit </td></tr>';
}
}
?>
</table>
</body>
</html>
Apparently you already have the values you need in stick_form.php:
else if(isset($_GET["id"])){
$qry = mysqli_query($dbc,"Select * From table1 Where id='".$_GET["id"]."'");
while($row=mysqli_fetch_array($qry,MYSQLI_ASSOC)){
$vid=$row["id"];
$vname=$row["name"];
$vcaption=$row["caption"];
$vvideo=$row["video"];
}
Try replacing this part of the code of stick_form.php:
<td><input type="text" class="bigger_textbox" name="name" value="<?php if (isset($_POST['name'])) {echo htmlentities($_POST['name']);}?>"></td></tr>
<tr><td>Caption</td>
<td><input type="text" class="bigger_textbox" name="caption" value="<?php if (isset($_POST['caption'])) {echo htmlentities($_POST['caption']);}?>"></td></tr>
<tr><td>Video</td>
<td><input type="text" class="bigger_textbox" name="video" value="<?php if (isset($_POST['video'])) {echo htmlentities($_POST['video']);}?>" </td></tr>
With:
<td><input type="text" class="bigger_textbox" name="name" value="<?php echo $vname; ?>"></td></tr>
<tr><td>Caption</td>
<td><input type="text" class="bigger_textbox" name="caption" value="<?php echo $vcaption; ?>"></td></tr>
<tr><td>Video</td>
<td><input type="text" class="bigger_textbox" name="video" value="<?php echo $vvideo; ?>"></td></tr>
Update
As you commented, after clicking the edit button, your form fields get empty. That's because you're not setting the correct variables in this part of your code:
if(isset($_POST["button_edit"])){
$id = $_POST["id"];
$name = $_POST['name'];
$caption = $_POST['caption'];
$video = $_POST['video'];
$qry = mysqli_query($dbc,"Update table1 Set name='$name', caption='$caption', video='$video' Where id='$id'");
Change it to:
if(isset($_POST["button_edit"])){
$vid = $_POST["id"];
$vname = $_POST['name'];
$vcaption = $_POST['caption'];
$vvideo = $_POST['video'];
$qry = mysqli_query($dbc,"Update table1 Set name='$vname', caption='$vcaption', video='$vvideo' Where id='$vid'");
Hope it helps.
I'm trying to update user profile with session. Suppose, the user profile page will update accordingly to the profile of the logged in user. Here's the sample code of user_profile.php:-
<?php
session_start();
ob_start();
include("../function/dbconnect.php");
include("header.php");
?>
<html>
<body>
<?php
if(isset($_SESSION['VALID_USER'])){
if(isset($_POST['submit']))
{
$username = $_POST['username'];
$password = $_POST['password'];
$s=mysql_query("UPDATE tbl_staffs SET username='$username', password='$password' WHERE username='".mysql_real_escape_string($_SESSION["VALID_USER"])."'");
if ($s)
{ echo "<script type='text/javascript'>alert('Successful - Record Updated!'); window.location.href = 'user_profile.php';</script>"; }
else
{ echo "<script type='text/javascript'>alert('Unsuccessful - ERROR!'); window.location.href = 'user_profile.php';</script>"; }
}
$query1=mysql_query("SELECT * FROM tbl_staffs WHERE username='".mysql_real_escape_string($_SESSION["VALID_USER"])."' AND user_levels = '".mysql_real_escape_string('1')."'");
$query2=mysql_fetch_array($query1);
?>
<form action="user_profile.php" method="POST">
<div>Your Profile</div>
<table border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td><div>Username:</div></td>
<td><input type="text" name="username" value="<?php echo $query2['username']; ?>" /></td>
</tr>
<tr>
<td><div align="left" id="tb-name">Password:</div></td>
<td><input type="text" name="password" value="<?php echo $query2['password']; ?>" /></td>
</tr>
</table>
<input type="submit" name="submit" value="Update" />
</form>
<?php
// close while loop
}}
?>
<?php
// close connection;
mysql_close();
?>
</br>
</body>
</html>
The page returns blank. There are several other codes that I'm working on for the user_profile.php page too but, the results that I get are the same... I used below codes for admin to update user profile.
include('function/dbconnect.php');
if(isset($_GET['id']))
{
$id=$_GET['id'];
if(isset($_POST['submit']))
{
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
$user_type = $_POST['user_type'];
$query3 = mysql_query("UPDATE tbl_staffs
SET username='$username', email='$email', password='$password', WHERE id='$id'");
if ($query3)
{ echo "<script type='text/javascript'>alert('Successful - Record Updated!'); window.location.href = 'user_list.php';</script>"; }
else
{ echo "<script type='text/javascript'>alert('Unsuccessful - ERROR!'); window.location.href = 'user_list.php';</script>"; }
}
$query1=mysql_query("SELECT * FROM tbl_staffs WHERE id='$id'");
$query2=mysql_fetch_array($query1);
<form method="post">
<tr>
<td><b>Username:</b></td><td><input type="text" name="username" style="width:255px" value="<?php echo $query2['username']; ?>" /></td>
</tr>
<tr>
<td><b>Email:</b></td><td><input type="text" name="email" style="width:255px" value="<?php echo $query2['email']; ?>" /></td>
</tr>
<tr>
<td><b>Password:</b></td><td><input type="text" name="password" style="width:255px" value="<?php echo $query2['password']; ?>" /></td>
</tr>
<tr>
<td colspan="2" align="right">
<br />
<span title="Click to update the user details"><input type="submit" name="submit" value="Update" /></span>
</td>
</tr>
</table>
</form>
<?php
}
?>
Apparently, it works fine as it is. Though, when I tried to imply the codes for user so that they can update their own profile, the codes won't work. Where am I doing it wrong?
first check your session is exist or not and then replace ".mysql_real_escape_string($_SESSION["VALID_USER"])." in your query by a variable like
$VALID_USER=mysql_real_escape_string($_SESSION["VALID_USER"]);
if(isset($_POST['submit']))
{
$username = $_POST['username'];
$password = $_POST['password'];
$s=mysql_query("UPDATE tbl_staffs SET username='$username', password='$password' WHERE username='$VALID_USER");
if ($s)
{ echo "<script type='text/javascript'>alert('Successful - Record Updated!'); window.location.href = 'user_profile.php';</script>"; }
else
{ echo "<script type='text/javascript'>alert('Unsuccessful - ERROR!'); window.location.href = 'user_profile.php';</script>"; }
}
$query1=mysql_query("SELECT * FROM tbl_staffs WHERE username='$' AND user_levels = '".mysql_real_escape_string('1')."'");
$query2=mysql_fetch_array($query1);
I have virtually no programming experience and trying this first project, I am a bit stuck on how to update the database, so I click on edit and the correct record gets loaded into the edit screen update.php
When I click update, I get the message from updated.php saying that the database has been updated, but the database does not get updated, when I display the records they are the same as before the update, thanks in advance for all your help.
the following code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Form Edit Data</title>
</head>
<body>
<table border=1>
<tr>
<td align=center>Form Edit Employees Data</td>
</tr>
<tr>
<td>
<table>
<?
$user_name = "";
$password = "";
$database = "";
$server = "localhost";
mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database);
$id = $_GET['id'];
$order = "SELECT * FROM MY_ID where ID = ' " .$id . " ' ";
$result = mysql_query($order);
$row = mysql_fetch_array($result);
?>
<form method="post" action="edit_data.php"?id=<?= $id ?>>
<input type="text" name="id" value="<? echo "$row[ID]"?>">
<tr>
<td>First Name</td>
<td>
<input type="text" name="FirsName" size="20" value="<? echo "$row[FirstName]"?>">
</td>
</tr>
<tr>
<td>Sur Name</td>
<td>
<input type="text" name="SurName" size="40" value="<? echo "$row[SurName]"?>">
</td>
</tr>
<tr>
<td>Address</td>
<td>
<input type="text" name="Address" size="40" value="<? echo "$row[Address]"?>">
</td>
</tr>
<tr>
<td align="right">
<input type="submit" name="submit" value="submit">
</td>
</tr>
</form>
</table>
</td>
</tr>
</table>
</body>
</html>
and here is the other file
<?php
$user_name = "";
$password = "";
$database = "";
$server = "";
mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database);
$id = $_REQUEST['ID'];
$FirstName = trim(mysql_real_escape_string($_POST["FirstName"]));
$SurName = trim(mysql_real_escape_string($_POST["SurName"]));
$Address = trim(mysql_real_escape_string($_POST["Address"]));
$sql = "UPDATE MY_ID SET FirstName='$FirstName',SurName='$SurName',Address='$Address' WHERE ID='$id'";
$result=mysql_query($sql);
if ($result){
echo "Successful";
echo "<BR>";
echo "<a href='edit.php'>View result</a>";
}
else {
echo "ERROR";
}
?>
Looks like you forget the double quotation mark and the full stop. You should write it as: '".$example."'
$sql = "UPDATE MY_ID SET FirstName='".$FirstName."',SurName='".$SurName."',Address='".$Address.:' WHERE ID='".$id."'";
It is because your form method is POST, and you are trying to GET ID.
Probably ID returns null.
My suggestion is to put a hidden input in your form as with name="ID", then read it in your posted page as $_POST["ID"];
Yes, the answer is as Mansours said. You should not use single quota to your variable.
So, it's bad practice writing code something like this:
<input type="text" value="<?php echo "$row[name]"; ?>">
it should be
<input type="text" value="<?php echo $row['name']; ?>">
it would be clear, and also, when inserting or updating the record you should write as follow:
$sql = "UPDATE MY_ID SET FirstName='" . $FirstName . "',
SurName='" . $SurName . "',
Address='" . $Address . "'
WHERE ID='" . $id . "'";
mysql_query($sql);
hey i am new here any one can help me with this chunk of code in php and mysql
i know that this is a little mistake but i could not know where is the error and thank you.
this is the code :
//index.php
<html>
<head>
<title>Search for a user</title>
</head>
<body>
<h2> Search for a user below:</h2><br /><br />
<form action="profileprocess.php" method="get">
<table>
<tr>
<td>Username:</td><td><input type="text" id="username" name="username" /></td></tr>
<tr>
<td><input type="submit" name="submit" id="submit" value="View Profile" /></td>
</tr>
</table>
</form>
</body>
</html>
// profileprocess.php
<html>
<head>
<title><?php echo $username; ?> <?php echo $lastname; ?>s profile</title>
</head>
<body>
<?php
if(isset($_GET['username'])){
$username = $_GET['username'];
mysql_connect("localhost", "root", "") or die ("could not connect t the server");
mysql_select_db("users") or die("this database was not found");
$userquery = mysql_query("SELECT * FROM users WHERE username='$username'") or die("the query could be fale please try again");
if(mysql_num_rows($userquery) != 1){
die("that username could not be found!");
}
while($row = mysql_fetch_array($userquery, MYSQL_ASSOC)){
$firstname = $row['firstname'];
$lastname = $row['lastname'];
$email = $row['email'];
$dbusername = $row['username'];
$activated = $row['activated'];
$access = $row['access'];
}
if($username != $dbusername){
die ("there has been a fatal error please try again. ");
}
if($activated == 0){
$active = "this account has not been activated";
}else{
$active = "ths account has been activated";
}
if($access == 0){
$admin = "this user is not administrator";
}else{
$admin = "this user is an administrator";
}
?>
<h2><?php echo $username; ?> <?php echo $lastname; ?>s profile</h2>
<table>
<tr>
<td>firstname:</td><td><?php echo $firstname; ?></td>
</tr>
<tr>
<td>lastname:</td><td><?php echo $lastname; ?></td>
</tr>
<tr>
<td>email:</td><td><?php echo $email; ?></td>
</tr>
<tr>
<td>username:</td><td><?php echo $dbusername; ?></td>
</tr>
<tr>
<td>activated:</td><td><?php echo $active; ?></td>
</tr>
<tr>
<td>access:</td><td><?php echo $admin; ?></td>
</tr>
</table>
<?php
}else die("You need to specify a username!");
?>
</body>
</html>
//// any help????
I just run this code on my XAMPP server and it seems to work fine.
<html>
<head>
<title>Search for a user</title>
</head>
<body>
<h2> Search for a user below:</h2><br /><br />
<form action="" method="get">
<table>
<tr>
<td>Username:</td><td><input type="text" id="username" name="username" /></td></tr>
<tr>
<td><input type="submit" name="submit" id="submit" value="View Profile" /></td>
</tr>
</table>
</form>
</body>
</html>
<?php
if($_GET['username'] != ''){
echo $_GET['username'];
} else
die('doesnt work'); ?>
One problem i definitely see is that you have used echo at the start of the page and the query is not running. That is going to throw up errors.
Also, please tell us what the errors are, so that we can try and help you better.
Here is my code below. The problem is when I try to update info it instead clears all records and does not update. How can I get this script to update and not clear. Also, I have used this before and it worked fine but all the sudden it doesn't.. I might have removed something important.
<strong>Update multiple rows in mysql</strong><br>
<?php
$mysql_host = "mysql.com";
$mysql_user = "username";
$mysql_pass = "password";
$mysql_database = "dbname";
$tbl_name="test_mysql"; // Table name
// Connect to server and select databse.
mysql_connect("$mysql_host", "$mysql_user", "$mysql_pass")or die("cannot connect");
mysql_select_db("$mysql_database")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
// Count table rows
$count=mysql_num_rows($result);
$id = array();
?>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<form name="form1" method="post" action="">
<tr>
<td>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<tr>
<td align="center"><strong>Id</strong></td>
<td align="center"><strong>Name</strong></td>
<td align="center"><strong>Lastname</strong></td>
<td align="center"><strong>Email</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="center"><? $id[]=$rows['id']; ?><? echo $rows['id']; ?></td>
<td align="center"><input name="name[]" type="text" id="name" value="<? echo $rows['name']; ?>"></td>
<td align="center"><input name="lastname[]" type="text" id="lastname" value="<? echo $rows['lastname']; ?>"></td>
<td align="center"><input name="email[]" type="text" id="email" value="<? echo $rows['email']; ?>"></td>
</tr>
<?php
}
?>
<tr>
<td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
<?php
// Check if button name "Submit" is active, do this
if(isset($_POST['Submit'])){
for($i=0;$i<$count;$i++){
$sql1="UPDATE $tbl_name SET name='$name[$i]', lastname='$lastname[$i]', email='$email[$i]' WHERE id='$id[$i]'";
$result1=mysql_query($sql1);
}
}
if($result1){
echo "Good";
////header("location:update_multiple.php");
}
mysql_close();
?>
You have using wrong set of variables,
try
$name[$i] <-- access local variable, an array called $name
$_POST["name"][$i] <-- access $_POST, the form name instead
I would suggest you make use $row["id"] as index key (name[$row["id"]]),
instead of using sequential indexed (key (0, 1, 2...)
None of your variables are defined in your SQL ($name, $lastname, $email, $id).
In your for loop, use $_POST['name'][$i] and so forth.
Also, it seems like you have forgotten to put your id in some form (hidden) field?
try this:
<?php require_once('Connections/tlsc_conn.php');
mysql_select_db($database_tlsc_conn, $tlsc_conn);
$query_Recordset1 = "SELECT * FROM tbl_name";
$Recordset1 = mysql_query($query_Recordset1, $tlsc_conn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
if(isset($_POST['submit'])) {
// $count = count($_POST['id']);
// $count=mysql_num_rows($Recordset1);
$submit = $_GET['submit'];
$i = ($_POST['count']);
$name = ($_POST['name']);
$lastname = ($_POST['lastname']);
$email = ($_POST['email']);
$id = ($_POST['id']);
for($i=0;$i<$count;$i++){
$sql1="UPDATE $tbl_name SET name='{$_POST['name'][$i]}',
lastname='{$_POST['lastname'][$i]}',
email='{$_POST['email'][$i]}'
WHERE id='{$_POST['id'][$i]}'";
$row_Recordset1=mysql_query($sql1);
}
if($row_Recordset1){
header("location:lulu.php");
exit;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form name="form2" method="post" action="">
<table width="634" border="1">
<tr>
<td>id</td>
<td>name</td>
<td>lastname</td>
<td>email</td>
</tr>
<?php do { ?>
<tr>
<td><?php $id[]=$row_Recordset1['id']; ?><?php echo $row_Recordset1['id']; ?>
<input name="id[]" type="hidden" value="<?php echo $row_Recordset1['id']; ?>" /></td>
<td><input name="name[]" type="text" value="<?php echo $row_Recordset1['name']; ?>"></td>
<td><input name="lastname[]" type="text" value="<?php echo $row_Recordset1['lastname']; ?>"></td>
<td><input name="email[]" type="text" value="<?php echo $row_Recordset1['email']; ?>"> </td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<p>
<input type="submit" name="submit" value="Submit" />
</p>
</form>
<p>
</p>
</body>
</html>
Used this command to change multiple entries in the database:
$sql = "UPDATE users SET name = ?, lastname = ?, email = ? WHERE id = '{$_SESSION['id']}'";