Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

Adding search function to the page


  • You cannot reply to this topic
No replies to this topic

#1 Irin

  • Community Member
  • 740 posts
  • Real Name:Irina
  • Gender:Female
  • Location:USA

Posted 21 October 2011, 16:13

Hello. I'm trying to add a search box on my item export page in admin panel, so when a list of products is populated, I can look up a specific product on that list by keywords (name, model). I managed to add a Search box on the page, but when I input my keywords, nothing happens, the page just refreshes, but doesn't show the product that I'm looking for. There is obviously something that I'm missing here. Any help will be appreciated. Here is the code on my item_export.php page:
<?php
require('includes/application_top.php');
if (!$_POST['submit'])
{
  ?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//DE">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<!--- BOF Simple Search Box //-->
<script language="JavaScript" type="text/javascript">
function clearDefault(dw) {
  if (dw.defaultValue==dw.value) dw.value = ""
}
function Default(w) {
  if (w.value=="") w.value = "<?php echo SEARCH_VALUE; ?>"
}
</script>
<!--- EOF Simple Search Box //-->
</head>
<body id="products">
<!-- header //-->
<?php require(DIR_WS_INCLUDES.'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
	<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
		<!-- left_navigation //-->
		<?php require(DIR_WS_INCLUDES.'column_left.php'); ?>
		<!-- left_navigation_eof //-->
	  </table></td>
	<!-- body_text //-->
	<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
		<tr>
		  <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
		</tr>
		<tr>
				<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
			  </tr>
		<tr>
		  <td><?php echo tep_draw_form(BOX_EXPORT_ITEMS, FILENAME_EXPORT_ITEMS, '', 'post'); ?>
			<table border="0" width="100%" cellspacing="0" cellpadding="0">
			  <tr>
				<td class="main"><?php echo TABLE_HEADING_EXPORT_ITEMS; ?>  
<?php
   if ($exportfile->Export == "") {
?>
  <A target="_blank" href="product_export.php?export=html&<?php echo tep_get_all_get_params(array('action')) ?>"><IMG
			title="Printer Friendly" height=16 alt="Printer Friendly"
			src="images/print.gif" width=16
			border=0></A>
  <A href="product_export.php?export=excel&<?php echo tep_get_all_get_params(array('action')) ?>"><IMG
			title="Export to Excel" height=16 alt="Export to Excel"
			src="images/exportxls.gif" width=16
			border=0></A>
  <A href="product_export.php?export=word&<?php echo tep_get_all_get_params(array('action')) ?>"><IMG
			title="Export to Word" height=16 alt="Export to Word"
			src="images/exportdoc.gif" width=16
			border=0></A>
  <a href="product_export.php?export=csv&<?php echo tep_get_all_get_params(array('action')) ?>"><IMG
			title="Export to csv" height=16 alt="Export to csv"
			src="images/exportcsv.gif" width=16
			border=0></a>
<?php
}
else {
}
?>
			  </td>
			  </tr>
			  <tr>
				<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
			  </tr>
			  <tr>
				<td class="main">
				<form name="quick_find" action="item_export.php" method="get">
	  <table width="1" border="0" style="background: black; vertical-align: bottom;">
	  <tr>
		<td>
		  <div align="right">
			  <!-- This is the input box to enter keywords etc -->
			<!--- BOF Simple Search Box //-->
			<input type="text" name="keywords" maxlength="30" value="Search..." onFocus="clearDefault(this)" onBlur="Default(this)">
			<!--- EOF Simple Search Box //-->
			<input type="hidden" name="search_in_description" value="1" />
			<input type="hidden" name="inc_subcat" value="1" />
			  </div>
		</td>
		  <td>
		  <div align="left" style="border: 1px solid #333333;">
			  <!-- OSC Search Submit Button Below -->
			<?php echo tep_image_submit('button_search.gif', HEADING_TITLE_SEARCH); ?>
			<!-- Default Gray Search Submit Button Below -->
			<!--<input type="submit" name="search" value="Search" class="formfield" border="0" width="79" height="25">-->
		  </div>
		</td>
		</tr>
	  </table>
</form>
				  <table border="1" width="100%" cellspacing="0" cellpadding="2">
					<tr class="dataTableHeadingRow">
					  <td class="dataTableHeadingContent">ID</td>
					  <td class="dataTableHeadingContent">Name</td>
					  <td class="dataTableHeadingContent">Model</td>
					  <td class="dataTableHeadingContent">Description</td>
					  <td class="dataTableHeadingContent">Quantity</td>
					  <td class="dataTableHeadingContent">Price</td>
					</tr>
					<?php
	$products_query_raw = "select p.products_id, pd.products_name, p.products_model, pd.products_description, p.products_quantity, p.products_price, p.products_price1, p.products_price2, p.products_price3, p.products_price4, p.products_price5, p.products_price6, p.products_price7, p.products_price8, p.products_price1_qty, p.products_price2_qty, p.products_price3_qty, p.products_price4_qty, p.products_price5_qty, p.products_price6_qty, p.products_price7_qty, p.products_price8_qty, p.products_qty_blocks, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'order by p.products_id";
	$products_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $products_query_raw, $products_query_numrows);
	$products_query = tep_db_query($products_query_raw);
	while ($products = tep_db_fetch_array($products_query)) {
?>
				 <tr class="dataTableRow">
					<td class="dataTableContent"><b><?php echo $products['products_id']; ?></b></td>
					  <td class="dataTableContent"><?php echo $products['products_name']; ?></td>
					  <td class="dataTableContent"><?php echo $products['products_model']; ?></td>
					  <td class="dataTableContent"><?php echo $products['products_description']; ?></td>
					  <td class="dataTableContent"><?php echo $products['products_quantity']; ?></td>
					  <td class="dataTableContent"><?php
  if(($products['products_price1_qty'] > 0) && ($products['products_price2_qty'] > 0)) {
	echo $products['products_price1_qty'] . ' - ' . $products['products_price2_qty'] . ': $' . $products['products_price1'] . '<br>';
}
if(($products['products_price1_qty'] > 0) && ($products['products_price2_qty'] < 1)) {
   echo $products['products_price1_qty'] . ' + : $' . $products['products_price1'] . '<br>';
}
if(($products['products_price2_qty'] > 0) && ($products['products_price3_qty'] > 0)) {
	echo $products['products_price2_qty'] . ' - ' . $products['products_price3_qty'] . ': $' . $products['products_price2'] . '<br>';
}
if(($products['products_price2_qty'] > 0) && ($products['products_price3_qty'] < 1)) {
   echo $products['products_price2_qty'] . ' + : $' . $products['products_price2'] . '<br>';
}
if(($products['products_price3_qty'] > 0) && ($products['products_price4_qty'] > 0)) {
	echo $products['products_price3_qty'] . ' - ' . $products['products_price4_qty'] . ': $' . $products['products_price3'] . '<br>';
}
if(($products['products_price3_qty'] > 0) && ($products['products_price4_qty'] < 1)) {
   echo $products['products_price3_qty'] . ' + : $' . $products['products_price3'] . '<br>';
}
if(($products['products_price4_qty'] > 0) && ($products['products_price5_qty'] > 0)) {
	echo $products['products_price4_qty'] . ' - ' . $products['products_price5_qty'] . ': $' . $products['products_price4'] . '<br>';
}
if(($products['products_price4_qty'] > 0) && ($products['products_price5_qty'] < 1)) {
   echo $products['products_price4_qty'] . ' + : $' . $products['products_price4'] . '<br>';
}
if(($products['products_price5_qty'] > 0) && ($products['products_price6_qty'] > 0)) {
	echo $products['products_price5_qty'] . ' - ' . $products['products_price6_qty'] . ': $' . $products['products_price5'] . '<br>';
}
if(($products['products_price5_qty'] > 0) && ($products['products_price6_qty'] < 1)) {
   echo $products['products_price5_qty'] . ' + : $' . $products['products_price5'] . '<br>';
}
if(($products['products_price6_qty'] > 0) && ($products['products_price7_qty'] > 0)) {
	echo $products['products_price6_qty'] . ' - ' . $products['products_price7_qty'] . ': $' . $products['products_price6'] . '<br>';
}
if(($products['products_price6_qty'] > 0) && ($products['products_price7_qty'] < 1)) {
   echo $products['products_price6_qty'] . ' + : $' . $products['products_price6'] . '<br>';
}
if(($products['products_price7_qty'] > 0) && ($products['products_price8_qty'] > 0)) {
	echo $products['products_price7_qty'] . ' - ' . $products['products_price8_qty'] . ': $' . $products['products_price7'] . '<br>';
}
if(($products['products_price7_qty'] > 0) && ($products['products_price8_qty'] < 1)) {
   echo $products['products_price7_qty'] . ' + : $' . $products['products_price7'] . '<br>';
}
if($products['products_price8_qty'] > 0) {
	echo $products['products_price8_qty'] . ' + : $' . $products['products_price8'];
}
?></td>
					</tr>
<?php
	}
?>
				  </table>
				  </td>
			  </tr>
			  <tr>
				<td colspan="4"><table border="0" width="100%" cellspacing="0" cellpadding="2">
				  <tr>
					<td class="smallText" valign="top"><?php echo $products_split->display_count($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
					<td class="smallText" align="right"><?php echo $products_split->display_links($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('page', 'info', 'x', 'y', 'cID'))); ?></td>
				  </tr>
				 </td>
			   </tr>
			  <tr>
				<td> </td>
			  </tr>
			</table>
			</form>
		  </td>
		</tr>
	  </table></td>
  </tr>
</table>
<!-- footer //-->
<center>
  <font color="#666666" size="2"></font>
</center>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php
}
require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

Thank you!