Warning-I'm a newbie!
Here's my problem.
I want to be able to delete a database record from an HTML page using a checkbox after each record and using one submit button to delete them all at once.
The database is storing transaction information. This info is displayed on an HTML page for company employees to see after successfully logging in. Once the page is printed, I want to have a way so that they can select a record using a checkbox and delete the ones selected with a submit button at the bottom of the page. I need to delete each record based on account number stored in the database field as 'account'.
Here's how I retrieve the records (there's probably a better way, I'm open to suggestions). All records are displayed in a table, so there's lots of "echo" formatting:
$query="SELECT * FROM info ORDER BY date";
$result=mysql_query($query)
or die ("Query failed.");
echo "<p align=\"center\"><font size=\"2\"><b>Payment Information</b>\n<br>".date("F d, Y")."</font></p>\n";
while ($row=mysql_fetch_array($result))
{
echo "<font size=\"2\">Transaction Date:".($row['date'])."</font>";
echo "<table width=\"90%\" border=\"1\" align=\"center\" cellpadding=\"2\" cellspacing=\"0\">\n";
// table headings
echo "<tr align=\"center\" valign=\"top\" bgcolor=\"#FFFFCC\">\n";
echo " <td><strong><font size=\"2\">Type</font></strong></td>\n";
echo " <td><strong><font size=\"2\">Account #</font></strong></td>\n";
echo " <td><strong><font size=\"2\">Name/Email</font></strong></td>\n";
echo " <td><strong><font size=\"2\">Address</font></strong></td>\n";
echo "</tr>\n";
// database values
echo "<tr align=\"center\">\n";
echo " <td><font size=\"2\">".stripslashes($row['btctype'])."</font></td>\n";
echo " <td><font size=\"2\">".stripslashes($row['account'])."</font></td>\n";
echo " <td><font size=\"2\">".stripslashes( $row['fname'])." ".stripslashes($row['mname'])." ".stripslashes($row['lname'])."<br>".stripslashes($row['email'])."</font></td>\n";
echo " <td><font size=\"2\">".stripslashes($row['address'])."<br>".stripslashes($row['city']).", ".stripslashes($row['zip'])."</font></td>\n";
echo "</tr>\n";
// more table headings
echo "<tr align=\"center\" valign=\"top\" bgcolor=\"#FFFFCC\">\n";
echo " <td><strong><font size=\"2\">Phone</font></strong></td>\n";
echo " <td><strong><font size=\"2\">Method</font></strong></td>\n";
echo " <td><strong><font size=\"2\">Card No./Exp</font></strong></td>\n";
echo " <td><strong><font size=\"2\">Amount</font></strong></td>\n";
echo "</tr>\n";
//more database values
echo "<tr align=\"center\">\n";
echo " <td><font size=\"2\">".stripslashes($row['phone'])."</font></td>\n";
echo " <td><font size=\"2\">".stripslashes($row['method'])."</font></td>\n";
echo " <td><font size=\"2\">".stripslashes($row['cc_account'])."<br>".stripslashes($row['m_exp'])." ".stripslashes($row['y_exp'])."</font></td>\n";
echo " <td><font size=\"2\">$".stripslashes($row['amount'])."</font></td>\n";
echo "</tr>\n";
// last table heading
echo "<tr>\n";
echo "<tr valign=\"top\" bgcolor=\"#FFFFCC\">\n";
echo " <td colspan=\"4\"><strong><font size=\"2\">Comments</font></strong></td>\n";
echo "</tr>\n";
// last database value
echo "<tr>\n";
echo " <td colspan=\"4\"><font size=\"2\">".($row['comments'])."</font></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br><br>\n";
}
I apologize for so much code. But thought it would be helpful to see that I'm calling each record from the array $row[xxx].
Thanks in advance. Any help is MUCH appreciated.