Hi All,
I have a function that displays a table with dropdown menus and textarea etc.
Then when the search functions is called from a button the results are displayed at the top of page rather than below.
Any ideas on how to fix this problem?
Can some give a quick example of how this works?
Sorry for the long code.. wasn';t sure what to post..
<?
include "../includes/functions.inc";
include "../includes/common_db.inc";
include("template.inc");
$link_id = db_connect($db_materials);
$tmpl = new Template(".", "keep");
$tmpl->set_file('page', "page.html");
$tmpl->set_var('TITLE', "Australian Self Adhesive Paper Search");
$tmpl->set_block('page', 'header');
$tmpl->pparse('out', 'header');
// Set action Variable
$action = isset($_GET['action']) ? $_GET['action'] : '';
if (isset($_POST['viewRecord'])) {viewPaperSummary($_POST['summaryId']);}
if (isset($_POST['viewFaceStock'])) {view($_POST['stockId']);}
if (isset($_POST['viewAdhesive'])) {viewAdhesives($_POST['adhesiveId']);}
if (isset($_POST['viewLiner'])) {viewLiners($_POST['linerId']);}
if (isset($_POST['searchNow'])) {fnSearchResults();}
function viewSearch() {
echo "\n\n<!-- START EXACT FORM -->\n";
echo "<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">\n";
echo "<input type=\"hidden\" name=\"commented\" value=\"set\">\n";
echo "<table class=\"display\"><tr class=row1><td width=\"550\" colspan=\"4\"><h3>Search for exact paper</td></tr></table>";
echo "<table class=\"display\">\n";
$colloPaperNameTitle = array('Collo Paper Name');
$colloPaperNameFunc = array(searchSAPaperName());
$colloPaperViewRecordType = array('submit');
$colloPaperViewRecordTitle = array('viewRecord');
$colloPaperViewRecordValue = array('View Record');
for($x = 0; $x<count($colloPaperNameTitle); $x++) {
echo "<tr><td width=\"200px\" colspan=\"2\" valign=\"top\">".$colloPaperNameTitle[$x]."</td>\n";
echo "<td width=\"200px\" colspan=\"4\">$colloPaperNameFunc[$x]</td>\n\n";
echo "<td width=50px>\n\n<input class=\"btn\" type=\"".$colloPaperViewRecordType[$x]."\" name=\"".$colloPaperViewRecordTitle[$x]."\" value=\"".$colloPaperViewRecordValue[$x]."\"></td></tr>\n\n";
}
echo "</table></form>";
echo "<hr>";
echo "<table class=\"display\"><tr class=row1><td width=\"550\" colspan=\"4\"><h3>Search criteria</td></tr></table>";
echo "<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">\n";
echo "<input type=\"hidden\" name=\"commented\" value=\"set\">\n";
echo "\n\n<!-- START MULRIVALUE FORM -->\n";
echo "<table class=\"display\">\n";
$searchColloPaperNameTitle = array('Paper Category','Manufactured Name','Computer Lookup Prefix','Face Stock','Adhesive','Liner','Supplier','Sutability','','','','','','');
$searchColloPaperNameTitle2 = array('','','','','','','','Foil','Bronze','Screen','Yellow Light','Opacity','Ice Bucket','Neck Labels');
$searchColloPaperCheckBox = array('checkbox','checkbox','checkbox','checkbox','checkbox','checkbox','checkbox','checkbox','checkbox','checkbox','checkbox','checkbox','checkbox','checkbox');
$searchColloPaperCheckBoxName = array('paperCategory','manufacturedName','clp','faceStock','','','','','','','','','','');
$searchColloPaperNameFunc = array(listCat(),'textarea','textarea',listFaceStock(),listAdhesive(),listLiner(),listSupplier(),foil(),bronze(),screen(),yellowLight(),opacity(),iceBucket(),neckLabel());
for($x = 0; $x<count($searchColloPaperNameTitle); $x++) {
echo "<tr><td width=\"150px\" valign=\"top\">".$searchColloPaperNameTitle[$x]."</td>\n";
echo "<td width=\"150px\" valign=\"top\" align=\"right\">".$searchColloPaperNameTitle2[$x]."</td>\n";
echo "<td width=\"50px\" align=\"center\"><input type=\"".$searchColloPaperCheckBox[$x]."\" name=\"".$searchColloPaperCheckBoxName[$x]."\" id=\"".$searchColloPaperCheckBoxName[$x]."\" value=\"on\"></td>\n\n";
echo "<td width=\"50px\">$searchColloPaperNameFunc[$x]</td></tr>\n\n";
}
echo "<tr><td align=\"right\" colspan=\"4\"><br><input type=\"submit\" name=\"searchNow\" class=\"btn\" value=\"Search Now\"></tr></td>";
echo "</table></form>";
}
function fnSearchResults() {
$paperCategoryId = $_POST['paperCategoryId'];
$query = "SELECT ausapapersummary.summaryId, ausapapersummary.paperCategoryId, aupapercategory.paperCategory, ausapapersummary.colloPaperName, ausapapersummary.stockId, austock.stockDescription, ausapapersummary.adhesiveId, auadhesive.adhesiveDescription, auliner.linerDescription, ausapapersummary.linerId FROM ausapapersummary ";
$query .="LEFT JOIN aupapercategory ON ausapapersummary.paperCategoryId = aupapercategory.papercategoryId
LEFT JOIN austock ON ausapapersummary.stockId = austock.StockId
LEFT JOIN auadhesive ON ausapapersummary.adhesiveId = auadhesive.adhesiveId
LEFT JOIN auliner ON ausapapersummary.linerId = auliner.linerId
WHERE ausapapersummary.paperCategoryId = '$paperCategoryId'";
$result = mysql_query($query);
if(!$result) error_message(sql_error());
$num_rows = mysql_num_rows($result);
// Set up SEARCH RESULTS
echo "\n\n<!-- Set up SEARCH RESULTS -->\n\n";
echo "<H4>$num_rows Records Found.</H4>";
echo "<table class=\"sortable\" id=\"search\">";
echo "<tr class=row1>";
echo "<th width=150px valign=top align=left nowrap>Summary ID</th>";
echo "<th width=150px valign=top align=left nowrap>Paper Category</th>";
echo "<th width=150px valign=top align=left nowrap>Collo Paper Name</th>";
echo "<th width=150px valign=top align=left nowrap>Face Stock</th>";
echo "<th width=150px valign=top align=left nowrap>Adhesive</th>";
echo "<th width=150px valign=top align=left nowrap>Liner</th>";
echo "</tr>";
while($query_data = mysql_fetch_array($result)) {
$summaryId = $query_data["summaryId"];
$paperCategory = $query_data["paperCategory"];
$colloPaperName = $query_data["colloPaperName"];
$stockId = $query_data["stockId"];
$stockDescription = $query_data["stockDescription"];
$adhesiveDescription = $query_data["adhesiveDescription"];
$linerDescription = $query_data["linerDescription"];
echo "<tr class=row2>\n";
echo "<td width=\"150px\" valign=\"top\">$summaryId</TD>\n";
echo "<td width=\"150px\" valign=\"top\">$paperCategory</TD>\n";
echo "<td width=\"150px\" valign=\"top\">$colloPaperName</TD>\n";
echo "<td width=\"150px\" valign=\"top\">$stockDescription</TD>\n";
echo "<td width=\"150px\" valign=\"top\">$adhesiveDescription</TD>\n";
echo "<td width=\"150px\" valign=\"top\">$linerDescription</TD>\n";
// echo "<TD WIDTH=\"25%\" ALIGN=\"CENTER\"><A HREF=\"javascript:open_window('$PHP_SELF?action=view_record&userid=$summaryId');\">View Record</A></TD>\n";
echo "</TR>\n";
}
echo "</table>";
}
// View Record Function
switch($action) {
case "viewFaceStock": fnViewFaceStockSpec(); break;
case "viewAddFaceStock": fnAddFaceStock(); break;
case "viewAdhesive": fnViewAdhesive(); break;
case "addAdhesive": fnAddAdhesive(); break;
case "viewLiner": fnViewLiner(); break;
case "addLiner": fnAddLiner(); break;
case "addFs": fnCreateFs(); break;
case "addFaceStock": viewAddFaceStock(); break;
case "viewPaperSummary": fnViewColloPaper(); break;
default: viewSearch(); break;
}
$tmpl->set_block('page', 'footer');
$tmpl->pparse('out', 'footer');
?>