php-Update table by selecting multiple primary keys and perform two different actions
Table beside which there is a check box and at the bottom of the table two buttons which has to perform dirrent action
action1- Change the status of selected rows.
action2- Send the selected rows to an email address.
I know to do these action for single record bt not for multiple. I have taken check box as array[] where it will store the primary keys of the selected records. I do not Know to use them in a professional manner.
Also note that I need to perform either of the two actions on single table. Please help me to do so.
<?php
$sql="SELECT * FROM transaction WHERE status='$selstatus'AND merchant_id='$selmerchantid' ORDER BY transaction_date AND transaction_date BETWEEN '$from' AND '$to' " ;
$result = mysql_query($sql) or die(mysql_error()); ;
$result = mysql_query($sql) or die(mysql_error());
// Print the column names as the headers of a table
echo '<table class="tableviewsales"><tr>';
for($i = 0; $i < mysql_num_fields($result); $i++) {
$field_info = mysql_fetch_field($result, $i);
echo "<th>{$field_info->name}</th>";
}
// Print the data
while($row = mysql_fetch_row($result)) {
echo "<tr>";
foreach($row as $_column) {
echo "<td>{$_column}</td>";
}
$transactionid = $row[0];
echo '<td> <input name="action[]" type="checkbox" value="'. $transactionid.'">' ;
echo "</tr>";
}
echo "</table>";
?>
</div>
<div id="action">
<table>
<tr>
<td> <input type="submit" value="Change Status" class="btn">
<input type="hidden" name="MM_update" value="changestatus" /> </td>
<td> <input type="submit" value="Send Report" class="btn">
<input type="hidden" name="MM_update" value="sendreport" /> </td>
</tr>
</table>
</div>
