Hello,
I have a problem. I would like to update certain columns in an mysql database by clicking on one submit button. I know there are many different ways on doing this but I would like to us a checkbox to select the columns I would like to edit or update. This is what I have so far:
[php]
<?php include 'acinclude/config.php'; include 'acinclude/function.php'; include("login/include/session.php"); if(!$session->logged_in){ header("Location: login/main.php"); } else { ?> <style type="text/css">
td.thick {font-weight:bold;}
</style>
</head>
<body>
<center>
[<a href = "index.php">Aircraft Status</a>]
[<a href = "index.php?status=up">UP</a>]
[<a href = "index.php?status=down">Down</a>]
[<a href = "index.php?status=FCF">FCF</a>]
[<a href = "index.php?status=down_and_FCF">Down and FCF</a>]
[<a href = "report.php">Status Report</a>]
[<a href = "update.php">Change Status</a>]
[<a href = "login/main.php">Account Controls</a>]
[<a href = "login/process.php">Logout</a>]
</center>
</br>
<center>
<form action="update1.php" method="post">
<table border="1">
<thead>
<tr>
<th>BUNO</th>
<th>MODEX</th>
<th>Status</th>
<th>Updated</th>
<th>Updated By</th>
<th>Reason</th>
<th>RTS</th>
<th>Check</th>
</tr>
</thead>
<?php
while ($row = mysql_fetch_array($all)){
$buno = $row[0];
$modex = $row[1];
$originalDate = $row[2];
$color = $row[4];
$fname = $row[5];
$lname = $row[6];
$reason = $row[7];
$rts = $row[8];
$date = date("m/d/y H:i",strtotime($originalDate));
print ' </table>
<input type="submit" name="submit" value="Update" /></td>
</form>
</center>
</body>
[/php]
update1.php
[php]
<?php include 'acinclude/config.php'; include 'acinclude/function.php'; include 'login/include/session.php'; if(isset($_REQUEST['submit'])){ if (isset($_REQUEST['checked'])) { $BUNO = $_POST['buno']; $MODEX = $_POST['modex']; $acstatus = $_POST['acstatus']; $reason = $_POST['reason']; $rts = $_POST['rts']; $uname = $_POST['user']; $i = -1; foreach ($BUNO as $BUNOS){ $row_modex = $MODEX[++$i]; $row_reason = $reason[$i]; $row_rts = $rts[$i]; $row_uname = $uname[$i]; $row_acstatus = $acstatus[$i]; $update_qr = 'UPDATE status SET STATUS ="'.$acstatus.'", username ="'.$uname.'", reason="'.$reason.'", rts="'.$rts.'" WHERE BUNO ="'.$BUNOS.'"'; $update = mysql_query($update_qr) or die('Invalid query: ' . mysql_error()); } header('Location: update.php'); } } else { echo "The Update button has not been clicked"; } ?>[/php]
I hope this explains everything. I will be more then happy to answer any question. Thank you in advance.