Re: Updateing a SQL select populated form



bangsundara@xxxxxxxxx wrote:
Hello
I sorry for writing late and thanks for the reply,
this is an eg,
what i want to do is , display all the records frm the table,
when the "flg" column is changed i want change MoveDate
and all the operation or over i want to update at once.
Thanks in Advance

-------------------
<html>
<head>
<title>test php</title>
</head>
<body>
<h3>Display 10 records at a time </h3>
<?php
$sv = "localhost";
$dbname = "test";
$user = "root";
$pass = "****";
$enc_disp = "utf8";
$enc_db = "utf8";
function cnv_enc($string, $to, $from) {
$det_enc = mb_detect_encoding($string, $from . ", " . $to);
if ($det_enc and $det_enc != $to) {
return mb_convert_encoding($string, $to, $det_enc);
}
else {
return $string;
}
}

$conn = mysql_connect($sv, $user, $pass) or die("DB Connect error");
mysql_select_db($dbname) or die("DB select error");

$st = 0;
$lim = 10;
$sql = "SELECT id, name, age, sex,place,flg,mdate FROM tbltest ORDER
BY id LIMIT $st, $lim;";
$res = mysql_query($sql, $conn) or die("Data extract error");
echo "<table border=\"1\">";
echo "<tr>";
echo "<td>ID</td>";
echo "<td>name</td>";
echo "<td>age</td>";
echo "<td>sex</td>";
echo "<td>place</td>";
echo "<td>flg</td>";
echo "<td>mdate</td>";
echo "</tr>";
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) {
echo "<tr>";
echo "<td>".$row["id"]."</td>";
echo "<td>".cnv_enc($row["name"], $enc_disp, $enc_db)."</td>";
echo "<td>".$row["age"]."</td>";
echo "<td>".cnv_enc($row["sex"], $enc_disp, $enc_db)."</td>";
echo "<td>".cnv_enc($row["place"], $enc_disp, $enc_db)."</td>";
echo "<td>".$row["flg"]."</td>";
echo "<td>".$row["mdate"]."</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($conn);
?>
</body>
</html>
------------------


OK, I'm not sure what your problem is, but I'll take a guess.

If you want the user to be able to change the flg entry, you need an input element; in this case I'd probably use a checkbox. The name would be something like "flg[]", with the value being the id.

When they submit the form, $_POST['flg'] will be an array with all of the values of the checked boxes. Just build your SQL statement (an UPDATE statement) to change the data you want.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================

.



Relevant Pages

  • Re: Multi Update with If Else Statement ... error
    ... I am trying to create an update statement that works well until I try ... You cannot troubleshoot a sql statement without knowing what it is. ... informative error message. ... Why in the world are you opening a recordset on a query that does not ...
    (microsoft.public.inetserver.asp.general)
  • Re: How to Use Cursor variable in Where Statement
    ... Do you have example how to do it in BULK operation? ... But why not doing it with just one SQL statement instead of using PL/SQL? ... See update statement in SQL Reference: ...
    (comp.databases.oracle.misc)
  • Re: How to update my access to current date??
    ... I try using the following sql statement.. ... > Syntax error in UPDATE statement. ... This email account is my spam trap so I ...
    (microsoft.public.inetserver.asp.general)
  • Re: How to update my access to current date??
    ... schreef in bericht news:OyLw6GFqEHA.644@tk2msftngp13.phx.gbl... ... I try using the following sql statement.. ... > Syntax error in UPDATE statement. ...
    (microsoft.public.inetserver.asp.general)