<?
	#---------------------------------------------------------------------#
	# This source code is (c)2000 White Pajamas, Inc                      #
	# see http://www.stonekeep.com/license.html for licensing information #
	#---------------------------------------------------------------------#

	#--------------------------------------------------------------------
	# $Id: mdelete.php3,v 1.8 2000/12/14 19:13:49 shevett Exp $
	#--------------------------------------------------------------------
	
	#
	# Delete a row from a table.
	#

	if ($f_yesno <> "No") {
		if ($f_func == "mdelete") { ?>
	
	<form method="post" action="nbrowse.php3">
	<input type=hidden name=f_process value="mdelete">
	<input type=hidden name=table value="<? echo $table ?>">
	<input type=hidden name=row value="<? echo $row ?>">
	<input type=hidden name=pkcolumn value="<? echo $pkcolumn ?>">
	<tr bgcolor=#BBBBBB>
	<td width=100% bgcolor=#202020 align=center>
	<table width=50% bgcolor=#bbbbbb cellspacing=2>
		<tr>
			<td colspan=2 bgcolor=#909090 align=center>
				<font color=#ffffff>
				Are you sure you want to delete<br>
				row '<b><? echo $row ?></b>' from table '<b><? echo "$table"; ?></b>'
			</td>
		</tr>
		<tr>
			<td bgcolor=#90FF90 align=center width=50%>
				<input type=submit name=f_yesno value="Yes">
			</td>
			<td bgcolor=#FF9090 align=center width=50%>
				<input type=submit name=f_yesno value="No">
			</td>
		</tr>
	</table>
	</td>
	</tr>
	
	<?
	
	} else {
	
		if ($f_process == "mdelete") {

			$pkc	=	db_primarykey("$table");
			
			$qstring = "delete from $table where ${pkc[0]}=${pkc[1]}${row}${pkc[1]}";
			$result=db_query("$qstring");
			$count = db_affected_rows($result);
			if ($count > 0) {
				$lastresult[0]=0;
				$lastresult[1]="Delete complete.  $count row(s) affected.";
			} else {
				$lastresult[0]=1;
				$lastresult[1]="Delete FAILED.  ($php_error)";
			}
			
		} else {
			#
			# We shouldn't have gotten here.
			#
			
			$lastresult[0]=1;
			$lastresult[1]="Unexpected condition occured! [mdelete.php3]";
		}
	}
	}
	
	?>
