Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ok, here is my dilema..............

Status
Not open for further replies.

WND

Programmer
Oct 13, 2002
7
US
Ok, here is my dilema................. I'm using DW MX to administer a database. Database is created, pages are created. I can connect to the database just fine, I can add records to the database just fine, I can update records in the database just fine. The problem is I just
can't figure out how to delete a record in a database. Ideally, I would like to be able to delete all records in a table, but I'd like to figure out how to just delete the individual ones first, and then move on to all records in a table (unless it's easier to go that way in the first place).

So, I've read a million and one tutorials, have tried the help file in DW MX, have browsed forum after forum and just can't figure it out. I know it's something stupid, and I'm missing it.

I'm posting the code that lists all the records below. Basically what I need to do is after the page is question (below) is printed out, I need to delete all the records in the database. Either record by record, table by table or whatever. It doesn't matter, I just can't figure out how to do it.

Is there ANYONE here that would be willing to help me figure this out (preferrably in dummy terms) I am so frusterated! LOL!

Thanks! Code below.



--------------------------------------------------------------------------------


<?php require_once('Connections/Accounting.php'); ?>
<?php
mysql_select_db($database_Accounting, $Accounting);
$query_DisplayAllPayments = &quot;SELECT * FROM Payments&quot;;
$DisplayAllPayments = mysql_query($query_DisplayAllPayments, $Accounting) or die(mysql_error());
$row_DisplayAllPayments = mysql_fetch_assoc($DisplayAllPayments);
$totalRows_DisplayAllPayments = mysql_num_rows($DisplayAllPayments);

mysql_select_db($database_Accounting, $Accounting);
$query_DisplayAllCharges = &quot;SELECT * FROM Account_Charges&quot;;
$DisplayAllCharges = mysql_query($query_DisplayAllCharges, $Accounting) or die(mysql_error());
$row_DisplayAllCharges = mysql_fetch_assoc($DisplayAllCharges);
$totalRows_DisplayAllCharges = mysql_num_rows($DisplayAllCharges);

mysql_select_db($database_Accounting, $Accounting);
$query_DisplayAllExpenses = &quot;SELECT * FROM Expenses&quot;;
$DisplayAllExpenses = mysql_query($query_DisplayAllExpenses, $Accounting) or die(mysql_error());
$row_DisplayAllExpenses = mysql_fetch_assoc($DisplayAllExpenses);
$totalRows_DisplayAllExpenses = mysql_num_rows($DisplayAllExpenses);

mysql_select_db($database_Accounting, $Accounting);
$query_DisplayAllNewClients = &quot;SELECT * FROM New_Client&quot;;
$DisplayAllNewClients = mysql_query($query_DisplayAllNewClients, $Accounting) or die(mysql_error());
$row_DisplayAllNewClients = mysql_fetch_assoc($DisplayAllNewClients);
$totalRows_DisplayAllNewClients = mysql_num_rows($DisplayAllNewClients);

$colname_DeleteRecord = &quot;1&quot;;
if (isset($HTTP_POST_VARS['Date'])) {
$colname_DeleteRecord = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['Date'] : addslashes($HTTP_POST_VARS['Date']);
}
mysql_select_db($database_Accounting, $Accounting);
$query_DeleteRecord = sprintf(&quot;SELECT * FROM Account_Charges WHERE `Date` = '%s' ORDER BY `Date` ASC&quot;,

$colname_DeleteRecord);
$DeleteRecord = mysql_query($query_DeleteRecord, $Accounting) or die(mysql_error());
$row_DeleteRecord = mysql_fetch_assoc($DeleteRecord);
$totalRows_DeleteRecord = mysql_num_rows($DeleteRecord);
?>
<html>
<head>
<title>Walston Net Design Accounting Management</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<STYLE TYPE=&quot;text/css&quot;>
BODY{
scrollbar-face-color:#D6D6CE;
scrollbar-shadow-color:#FFFFFF;
scrollbar-track-color:#D8D8D8;
scrollbar-3dlight-color:#B3D8FA;
scrollbar-arrow-color:#008000;
scrollbar-base-color:#FFFFFF;
scrollbar-darkshadow-color:#565CD0;
scrollbar-highlight-color:#3A69B6;
}
</style>
<script language=&quot;JavaScript&quot;>
function doClock(){ // By Paul Davis - var t=new Date(),a=doClock.arguments,str=&quot;&quot;,i,a1,lang=&quot;1&quot;;
var month=new Array('January','Jan', 'February','Feb', 'March','Mar', 'April','Apr', 'May','May', 'June','Jun', 'July','Jul', 'August','Aug',

'September','Sep', 'October','Oct', 'November','Nov', 'December','Dec');
var tday= new Array('Sunday','Sun','Monday','Mon', 'Tuesday','Tue', 'Wednesday','Wed','Thursday','Thr','Friday','Fri','Saturday','Sat');
for(i=0;i<a.length;i++) {a1=a.charAt(1);switch (a.charAt(0)) {
case &quot;M&quot;:if ((Number(a1)==3) && ((t.getMonth()+1)<10)) str+=&quot;0&quot;;
str+=(Number(a1)>1)?t.getMonth()+1:month[t.getMonth()*2+Number(a1)];break;
case &quot;D&quot;: if ((Number(a1)==1) && (t.getDate()<10)) str+=&quot;0&quot;;str+=t.getDate();break;
case &quot;Y&quot;: str+=(a1=='0')?t.getFullYear():t.getFullYear().toString().substring(2);break;
case &quot;W&quot;:str+=tday[t.getDay()*2+Number(a1)];break; default: str+=unescape(a);}}return str;
}
</script>
</head>

<body bgcolor=&quot;#FFFFFF&quot; leftmargin=&quot;0&quot; topmargin=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot;>
<table width=&quot;95%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; align=&quot;center&quot;>
<tr>
<td height=&quot;693&quot; valign=&quot;top&quot;><font class=&quot;titleBlue&quot;>

<em><font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;> </font></em>
<table width=&quot;100%&quot; border=&quot;0&quot; align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>
<tr valign=&quot;top&quot;>
<td width=&quot;17%&quot;><em><font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>
<script language=&quot;JavaScript&quot;>
document.write(doClock(&quot;W0&quot;,&quot;%20%20&quot;,&quot;M0&quot;,&quot;%20%20&quot;,&quot;D0&quot;,&quot;,%20&quot;,&quot;Y0&quot;));
</script>
</font></em></td>
<td width=&quot;83%&quot;><div align=&quot;right&quot;><font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><em><a href=&quot;javascript:window.print()&quot;><font

color=&quot;#000000&quot;>Click
here to print records</font></a></em> </font></div></td>
</tr>
</table>
<hr noshade size=&quot;1&quot; color=&quot;#000000&quot; width=&quot;98%&quot; align=&quot;left&quot;>
<p><font size=&quot;3&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><strong><em>New Charges</em></strong></font></p>
<table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;>
<tr>
<td width=&quot;10&quot;> </td>
<td width=&quot;190&quot;><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Date</font></td>
<td width=&quot;110&quot;><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Client</font></td>
<td width=&quot;118&quot;><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Service</font></td>
<td width=&quot;118&quot;><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Amount</font></td>
<td width=&quot;132&quot;><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Comments</font></td>
</tr>
<?php do { ?>
<tr>
<td height=&quot;22&quot;><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><a href=&quot;delete_record.php&quot;><img src=&quot;delete.gif&quot; width=&quot;8&quot;

height=&quot;7&quot; border=&quot;0&quot;></a></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllCharges['Date']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllCharges['Client']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllCharges['Service']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllCharges['Amount']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllCharges['Comments']; ?></font></td>
</tr>
<?php } while ($row_DisplayAllCharges = mysql_fetch_assoc($DisplayAllCharges)); ?>
</table>
<p><strong><font size=&quot;3&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Expenses</font></strong>
</p>
<table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;>
<tr>
<td> </td>
<td><strong><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Date</font></strong></td>
<td><strong><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Expense</font></strong></td>
<td><strong><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Amount</font></strong></td>
<td><strong><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Merchant</font></strong></td>
<td><strong><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Account</font></strong></td>
<td><strong><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Comments</font></strong></td>
</tr>
<?php do { ?>
<tr>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><a href=&quot;delete_record.php&quot;><img src=&quot;delete.gif&quot; width=&quot;8&quot; height=&quot;7&quot;

border=&quot;0&quot;></a></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllExpenses['Date']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllExpenses['Expense']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllExpenses['Amount']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllExpenses['Merchant']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllExpenses['Account']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllExpenses['Comments']; ?></font></td>
</tr>
<?php } while ($row_DisplayAllExpenses = mysql_fetch_assoc($DisplayAllExpenses)); ?>
</table>



<p><font size=&quot;3&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><strong><em>New <strong><font size=&quot;3&quot; face=&quot;Arial, Helvetica,

sans-serif&quot;>Clients</font></strong></em></strong></font>
<font size=&quot;3&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><strong><em> </em></strong></font>
</p>
<table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;>
<tr>
<td> </td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Date</font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Account_Number</font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Name</font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Business_Name</font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Email</font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Phone</font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Fax</font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Address</font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>City</font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>State</font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Zip</font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Contact_Person</font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Account_Type</font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Comments</font></td>
</tr>
<?php do { ?>
<tr>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><a href=&quot;delete_record.php&quot;><img src=&quot;delete.gif&quot; width=&quot;8&quot; height=&quot;7&quot;

border=&quot;0&quot;></a></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllNewClients['Date']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllNewClients['Account_Number']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllNewClients['Name']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllNewClients['Business_Name']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllNewClients['Email']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllNewClients['Phone']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllNewClients['Fax']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllNewClients['Address']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllNewClients['City']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllNewClients['State']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllNewClients['Zip']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllNewClients['Contact_Person']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllNewClients['Account_Type']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllNewClients['Comments']; ?></font></td>
</tr>
<?php } while ($row_DisplayAllNewClients = mysql_fetch_assoc($DisplayAllNewClients)); ?>
</table>



<p><font size=&quot;3&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><strong><em>Payments</em></strong></font>
<font size=&quot;3&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><strong><em> </em></strong></font>
</p>
<table border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;>
<tr>
<td> </td>
<td><strong><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Date</font></strong></td>
<td><strong><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Client</font></strong></td>
<td><strong><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Amount</font></strong></td>
<td><strong><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Check_Number</font></strong></td>
<td><strong><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Comments</font></strong></td>
</tr>
<?php do { ?>
<tr>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><a href=&quot;delete_record.php&quot;><img src=&quot;delete.gif&quot; width=&quot;8&quot; height=&quot;7&quot;

border=&quot;0&quot;></a></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllPayments['Date']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllPayments['Client']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllPayments['Amount']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllPayments['Check_Number']; ?></font></td>
<td><font size=&quot;1&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><?php echo $row_DisplayAllPayments['Comments']; ?></font></td>
</tr>
<?php } while ($row_DisplayAllPayments = mysql_fetch_assoc($DisplayAllPayments)); ?>
</table>
<p align=&quot;center&quot;><font color=&quot;#000000&quot; size=&quot;3&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><strong><a href=&quot;javascript: self.close()&quot;><font

color=&quot;#000000&quot;>Close Window</font></a></strong></font></p></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($DisplayAllPayments);

mysql_free_result($DisplayAllCharges);

mysql_free_result($DisplayAllExpenses);

mysql_free_result($DisplayAllNewClients);

mysql_free_result($DeleteRecord);
?>
 
[tt]

I don't know PHP but here's how I do it in VBScript.

On this example
I'm passing a recordset ID to know what record to delete on this page.




<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<!--#include file=&quot;Connections/myconn.asp&quot; -->

<%
Dim deleteme__MMColParam
deleteme__MMColParam = &quot;&quot;
if (Request.QueryString(&quot;id&quot;) <> &quot;&quot;) then deleteme__MMColParam = Request.QueryString(&quot;id&quot;)
%>
<%
set deleteme = Server.CreateObject(&quot;ADODB.Recordset&quot;)
deleteme.ActiveConnection = MM_myconn_STRING
deleteme.Source = &quot;Delete * FROM mytbl WHERE id = &quot; & deleteme__MMColParam
deleteme.CursorType = 0
deleteme.CursorLocation = 2
deleteme.LockType = 3
deleteme.Open()
deleteme_numRows = 0
%>
<%
response.redirect &quot;Updated_Page.asp&quot;
%>
<%
deleteme.Close()
%>


Note: Have you consider marking records deleted as suppossed to completely getting rid of them?




* * * * * * * * * * *
<%=Tony%>
cold.gif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top