Re: Updateing a SQL select populated form



On 4月6日, 午前3:52, Jerry Stuckle <jstuck...@xxxxxxxxxxxxx> wrote:

Thank you very much for your kind reply.
as per your advice, i made simple php like below pg,

now i have 2 doubt.

1.when i read a data to check box from database, how can i set
cheked when data is 1 not checked when data is 0.

Then
2. After displaying the data, whe the user clicked, then
date field can be entered, if not previous ino is retained
then the update whereever the user changed the checkbox and
date field onlt those info should be updated.

here is the sample code wher i have done till now

--------------------------
<?php
// connect to the database :mysql
$host="localhost"; // Host name.
$dbuser="test"; // MySQL username.
$dbpassword="******"; // MySQL password.
$database="test"; // Database name.
mysql_connect($host,$dbuser,$dbpassword) or die('Unable to connect to
thye database');
mysql_select_db($database) or die("Unable to select database");
$result = mysql_query("SELECT * FROM tbltest ORDER BY slno,empid");
$i = 0;

print "<form name='namestoupdate' method='post' action='tblupdate.php'>
\n";
print "<tr>";
print "<th nowrap> No</th>";
print "<th nowrap> Emp No</th>";
print "<th nowrap> Emp Name</th>";
print "<th nowrap> Amount</th>";
print "<th nowrap> Flg </th>";
print "<th nowrap> Date</th>";

while ($rec = mysql_fetch_array($result)) {
print "<input type='hidden' name='slno[$i]'
value='{$rec['slno']}' />";
print "<tr>";
print "<p>{$rec['slno']} {$rec['empid']} {$rec['empname']}
{$rec['amt']} <input type='checkbox' name='{$rec['slno']}'
value='{$rec['flg']}'> <input type='text' size='25' name='rec[$i]'
value='{$rec['date']}' /></p> ";
++$i;
}
print "</table>";
print "<p><input type='submit' value='ClickallChkbox' /></p>";
print "<input type='submit' value=' Clear' />";
print "<p><input type='submit' value='Update' /></p>";
print "</form>";
mysql_close();
?>
-------------------------


Thanki you very much in advance

-evolu
.



Relevant Pages

  • Re: Executing PHP files on remote web server
    ... I may be brand new to PHP but I'm not a rookie database developer. ... concept of avoiding SQL injections isn't that different. ... can't follow your advice about hiring a contractor. ...
    (comp.lang.php)
  • Web Developers - Happy Hearts And HDTV! - Lockergnome
    ... Certificate on your MSIIS Web server. ... getting data from a database is only half the problem. ... Zend recently started a series about building rock solid code in PHP. ... which provides bulk database conversion. ...
    (freebsd-questions)
  • Re: Techniques for Vulneability discovery
    ... in mind) so i searched the net for some free database driven software and came ... the first thing i did was grab some info about PHP programming and some MySQL ... I did some more reasearch on different types of web based "input validation" ... PHP and SQL docs, etc.. ...
    (Vuln-Dev)
  • Re: Techniques for Vulneability discovery
    ... in mind) so i searched the net for some free database driven software and came ... the first thing i did was grab some info about PHP programming and some MySQL ... I did some more reasearch on different types of web based "input validation" ... PHP and SQL docs, etc.. ...
    (Security-Basics)
  • Re: CSS + xhtml static site - going dynamic?
    ... PHP then fills each content area. ... A better alternative is to have PHP pull the content off a database. ... management - menus and page linking need to be done by hand. ... So the second part is to formally build the linking structure into the ...
    (uk.net.web.authoring)