Re: Updateing a SQL select populated form
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Sat, 05 Apr 2008 13:52:10 -0500
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
==================
.
- Follow-Ups:
- Re: Updateing a SQL select populated form
- From: bangsundara
- Re: Updateing a SQL select populated form
- References:
- Re: Updateing a SQL select populated form
- From: bangsundara
- Re: Updateing a SQL select populated form
- Prev by Date: Cheap Tag Heuer Link Watches Replica - TAG Heuer Watches Wholesale
- Next by Date: Re: I am not able to see the executed output at all
- Previous by thread: Re: Updateing a SQL select populated form
- Next by thread: Re: Updateing a SQL select populated form
- Index(es):
Relevant Pages
|