Index: trunk/ippMonitor/def/autocode.php
===================================================================
--- trunk/ippMonitor/def/autocode.php	(revision 9003)
+++ trunk/ippMonitor/def/autocode.php	(revision 9008)
@@ -20,4 +20,6 @@
 // ** TABLE RESTRICTIONS **
 
+echo "WHERE: $WHERE<br><br>\n";
+
 // query the database
 if ($WHERE) {
@@ -27,4 +29,6 @@
 }
 
+echo "SQL: $sql<br><br>\n";
+
 $qry = $db->query($sql);
 if (DB::iserror($db)) {
@@ -33,5 +37,5 @@
 }
 
-// ** BODY HTML **
+// ** HEAD CODE **
 
 // set up the table and form
@@ -72,5 +76,5 @@
 echo "</form>\n";
 
-// ** TAIL HTML **
+// ** TAIL CODE **
 
 menu_end();
Index: trunk/ippMonitor/def/detInputExp.d
===================================================================
--- trunk/ippMonitor/def/detInputExp.d	(revision 9003)
+++ trunk/ippMonitor/def/detInputExp.d	(revision 9008)
@@ -4,7 +4,7 @@
 MENU  ipp.detrend.dat
 
-BODY.HTML  test 1 <br>
-BODY.HTML  test 2 <br>
-BODY.HTML  test 3 <br>
+HEAD HTML  test head 1 <br>
+HEAD HTML  test head 2 <br>
+HEAD HTML  test head 3 <br>
 
 #     field      name       show        link to                 extras
@@ -15,5 +15,5 @@
 FIELD include,   include
 
-TAIL.HTML test tail 1 <br>
-TAIL.HTML test tail 2 <br>
-TAIL.HTML test tail 3 <br>
+TAIL HTML test tail 1 <br>
+TAIL HTML test tail 2 <br>
+TAIL HTML test tail 3 <br>
Index: trunk/ippMonitor/def/detResidExp.d
===================================================================
--- trunk/ippMonitor/def/detResidExp.d	(revision 9003)
+++ trunk/ippMonitor/def/detResidExp.d	(revision 9008)
@@ -4,13 +4,13 @@
 MENU  ipp.detrend.dat
 
-#     field      name       show            link to         extras
+#     field      name       show            link to             extras
 FIELD det_id,    det_id,    value
 FIELD iteration, iteration, value
 FIELD accept,    accept,    value
-FIELD exp_id, 	 exp_id,    value,          rawImfile.php,  exp_id=$exp_id
-FIELD b1_uri, 	 b1_uri,    image=$b1_uri,  display.php,    image=$b2_uri
-FIELD recipe, 	 recipe,    image=pic.png
+FIELD exp_id, 	 exp_id,    value,          rawImfile.php,      exp_id=$exp_id
+FIELD b2_uri, 	 b2_uri,    image=$b2_uri,  detResidImfile.php, det_id=$det_id,iteration=$iteration,exp_id=$exp_id,image=$b1_uri
+FIELD recipe, 	 recipe,    value
 FIELD bg,        backgnd,   value
 FIELD bg_stdev,  bg_stdev,  value
-FIELD b2_uri, 	 b2_uri,    none
+FIELD b1_uri, 	 b1_uri,    none
 # FIELD bg_mean_stdev, bg_mean_stdev
Index: trunk/ippMonitor/def/detResidImfile.d
===================================================================
--- trunk/ippMonitor/def/detResidImfile.d	(revision 9003)
+++ trunk/ippMonitor/def/detResidImfile.d	(revision 9008)
@@ -16,2 +16,4 @@
 FIELD b1_uri, b1_uri
 FIELD b2_uri, b2_uri
+
+TAIL PHP insert_image ('image');
Index: trunk/ippMonitor/def/masterDetrendImages.d
===================================================================
--- trunk/ippMonitor/def/masterDetrendImages.d	(revision 9008)
+++ trunk/ippMonitor/def/masterDetrendImages.d	(revision 9008)
@@ -0,0 +1,34 @@
+# this file is based on the detRunSummary.d file: it uses the same tables restricted to the 
+# master detrend runs which have been accepted
+
+TABLE detRunSummary, detRun
+TITLE Master Detrend Images
+FILE  masterDetrendImages.php
+MENU  ipp.detrend.dat
+
+HEAD PHP insert_image ('image');
+HEAD HTML extra <b> lines </b><br><br>
+
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detRunSummary.accept = 1
+WHERE detRun.position = detRunSummary.det_id
+WHERE detRun.iteration = detRunSummary.iteration
+
+#     field                    name           show         link to           extras
+FIELD detRunSummary.det_id,    det_id
+FIELD detRun.det_type,         type
+FIELD detRunSummary.iteration, iteration,   value,       detInputExp.php,  det_id=$detRunSummary.det_id,iteration=$detRunSummary.iteration
+FIELD *,                       resid,       value=resid, detResidExp.php,  det_id=$detRunSummary.det_id,iteration=$detRunSummary.iteration
+FIELD detRunSummary.bg,        bg
+FIELD detRunSummary.bg_stdev,  bg_stdev
+# FIELD bg_mean_stdev, bg_mean_stdev
+
+# this file illustrates a simple inner join to generate the output table
+# assuming no other dynamic restrictions are added, this generates the following query:
+# SELECT detRunSummary.det_id,detRunSummary.iteration,detRunSummary.iteration,detRun.det_type,detRunSummary.bg,detRunSummary.bg_stdev \
+# FROM detRunSummary, detRun \
+# WHERE detRunSummary.accept = 1 AND detRun.position = detRunSummary.det_id AND detRun.iteration = detRunSummary.iteration \
+# LIMIT 20
+
+TAIL HTML extra <b> tail lines </b><br>
+TAIL PHP  echo "this is a php line at the end<br>\n";
