mysql table row updation based on user input.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
 
i have a form for the user input with checkboxes and table rows for the user. The user can select the checkboxes which correspond to table rows in database. Depending on the selection of checkboxes i want to update the fields. For example:
 
checkboxessubstrate_typesubstrate_numpixelprocess_classprocess_logoperatorcdatectimelocationdurationtemperaturepressureultrasonicsolventpedotsolutionsolution_tempsubstrate_tempmaskcomment [input]  S4350absorber annealingMM2017-09-0514:18:15LF02124000fdsg [input]  M2340pedot annealingMM0000-00-0014:22:03LF01223000saddddddDate*: [input] (DD.MM.YY)
Time*: [input] (HH:MM:SS)

 [input] 
if the user selects some checkboxes and submits, then i want to take the cdate,ctime in table and calculate the difference from the current date and time,and enter the difference in duration.

The code for the above form is 

echo '<link rel="stylesheet" type="text/css" href="sql-query.css">';
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
   die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('fmfgui', $link);
if (!$db_selected) {
   die ('Can\'t use fmfgui : ' . mysql_error());
}

$res = mysql_query("select * from running_processes");
  if (!$res) {
  print "<p style=\"color:red;\">mysql error: ".mysql_error()."</p>\n";}
  
   $ncols = mysql_num_fields($res);
  print "<TABLE style='border: 1pt solid blue; border-collapse: collapse; cell-spacing: 0px'>";
  print "<TR>";
        print "<TD style='border-bottom-style: double; border-left: 1pt solid black; font-weight:bold; text-align:center'>checkboxes</TD>";
         for ( $i = 0; $i < $ncols; $i++ ) {
            $column_name  = mysql_field_name($res,$i);
            print "<TD style='border-bottom-style: double; border-left: 1pt solid black; font-weight:bold; text-align:center'>$column_name</TD>";
         }
  print "</TR>";
  
  print "<TR>";
  
  while ($row = mysql_fetch_array($res)) {
         $ncols = mysql_num_fields($res);
         print "<TD style='border: 1pt solid black cell-padding: 3px'><input type='checkbox' name=\"id[]\" value=\"".$row["id"]."\"> </TD>";  
         for ( $i = 0; $i < $ncols; $i++ ) {
                print "<TD style='border: 1pt solid black cell-padding: 3px'>$row[$i]</TD>";
         }
  print "</TR>";
  }
    print "</TABLE>\n";
    
$tdate=date("d.m.y");
echo "<h4>Date*:<input type='text' name='edate' value='$tdate'>";echo "(DD.MM.YY)";
echo "<br />";
$ttime=$ttime = date("H:i:s");
echo "<h4>Time*:<input type='text' name='etime' value='$ttime'>"; echo "(HH:MM:SS)";
echo "<br />";
echo "<br />";
echo "<input type='submit' name='submit' value='submit'>";
echo "</form>";


The problem is if the user selects more than one checkbox then how can i write the update command.

thanks

babu.


		
---------------------------------
How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos. Get Yahoo! Photos

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux