Jump to content

Recommended Posts

Hey everyone,

 

Please have a look at my code below. The idea with this page is to generate a report based on a date range. I’ve got the actual search on the date range to work but now I want to search on “Representatives” as well. It works when I select a rep from the dropdown and select a date range but as soon as I want to display all reps with a date range, it returns zero rows. I’ve tried using “%” and “*” as a value for “All Reps” but still it won’t fetch any rows. What am I doing wrong? Please help!! The code is a bit of a mess because I have quite a few queries doing different things on the page. Lower down is the code to select the info from the database into the dropdown. At the moment, I've set up the coding only to pull in unique entries.

 

Any feedback would be appreciated!!

 

Thanks,

 

Karen

 

<?php
// includes
include("../inc/conn.inc.php");
include("../inc/validate.inc.php");
?>
<?

$from_date = $_REQUEST['from_date'];
$to_date = $_REQUEST['to_date'];

if ($_POST['submit']) {
  		

	$sql_prop = "SELECT * FROM $db.iStock WHERE Trans_Date BETWEEN '".$from_date."' AND '".$to_date."' AND TMR_Name = '".$_REQUEST['reps']."' ORDER BY Trans_Date ASC";
	$result_prop = mysql_query($sql_prop);

	$sql_date = "SELECT * FROM $db.iStock WHERE Trans_Date BETWEEN '".$from_date."' AND '".$to_date."' AND TMR_Name = '".$_REQUEST['reps']."' ORDER BY Trans_Date ASC";
	$result_date = mysql_query($sql_date);
	$rs_date = mysql_fetch_array($result_date);

	//summation
	$sql_prop2 ="SELECT SUM(Quantity) AS total_quantity, SUM(Income) AS total_income, SUM(Purchased) AS total_purchased, SUM(Month_Income) AS total_month_income FROM $db.iStock WHERE Trans_Date BETWEEN '".$from_date."' AND '".$to_date."' AND TMR_Name = '".$_REQUEST['reps']."' ORDER BY Venue_Name ASC";
	$result_prop2 = mysql_query($sql_prop2) or die(error_report("Mysql Error", mysql_error()."\n\n$sql_rows", $_SERVER['REMOTE_ADDR']));
	$rs_prop2 = mysql_fetch_array($result_prop2);
	////

	$sql_rows = "SELECT COUNT(*) FROM $db.iStock WHERE Trans_Date BETWEEN '".$from_date."' AND '".$to_date."' AND TMR_Name = '".$_REQUEST['reps']."'";
	$result_rows = mysql_query($sql_rows);
	$rs_rows = mysql_fetch_array($result_rows);
	$numrows = $rs_rows[0];	




} else {
  		$sql_prop="SELECT * FROM $db.iStock ORDER BY Venue_Name ASC";
	$result_prop = mysql_query($sql_prop) or die(error_report("Mysql Error", mysql_error()."\n\n$sql_rows", $_SERVER['REMOTE_ADDR']));

	//summation
	$sql_prop2 ="SELECT SUM(Quantity) AS total_quantity, SUM(Income) AS total_income, SUM(Purchased) AS total_purchased, SUM(Month_Income) AS total_month_income FROM $db.iStock ORDER BY Venue_Name ASC";
	$result_prop2 = mysql_query($sql_prop2) or die(error_report("Mysql Error", mysql_error()."\n\n$sql_rows", $_SERVER['REMOTE_ADDR']));
	$rs_prop2 = mysql_fetch_array($result_prop2);
	/////

	$sql_rows = "SELECT COUNT(*) FROM $db.iStock ORDER BY Venue_Name ASC";
	$result_rows = mysql_query($sql_rows) or die(error_report("Mysql Error", mysql_error()."\n\n$sql_rows", $_SERVER['REMOTE_ADDR']));
	$rs_rows = mysql_fetch_array($result_rows);
	$numrows = $rs_rows[0];	

	$sql_date_row ="SELECT MAX(Trans_Date) AS to_date_max, MIN(Trans_Date) AS from_date_min FROM $db.iStock";
	$result_date_row = mysql_query($sql_date_row);
	$rs_date_row = mysql_fetch_array($result_date_row);


	}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>

<link href="../styles/opus_db.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style39 {font-size: 24px}
.style41 {font-size: 12px; padding-left: 10px; font-family: Arial, Helvetica, sans-serif;}
.style42 {color: #558ED5}
-->
</style>
<link href="../styles/opus_db_print.css" media="print" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="778" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#BECADE">
  <tr>
    <td valign="middle"><p align="right" class="head1"><br />
      <span class="style39"> iStock Online  </span></p>
     
  <table width="782" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
      <!--DWLayoutTable-->
      <tr>
        <td id="nodisplay" width="172" height="299" valign="top" bgcolor="#E9EDF4"><p class="head2"><strong> <u>Menu</u> </strong></p>
            <p class="body2"><strong>Online stock management<br />
              </strong><a href="alerts.php" style="color:#000000"><span class="style41">Alerts</span></a><br />
              <span class="body3"><a href="current_outlet.php" style="color:#000000;">Current Outlet stock bal</a></span><br />
              <a href="sales.php"><span class="body3 " style="color:#000000">Sales to date</span></a><br />
            <span class="body3"><a href="model.php" style="color:#000000">Model stock settings</a></span></p>
          <p class="body2"><strong>Management Reports<br />
              </strong><span class="body3 style42"><strong>Sales to Outlets</strong></span><br />
              <span class="body3">Sales by SKU</span><br />
              <span class="body3">Monthly report</span><br />
              <span class="body3">Rep Monthly Report</span><br />
            <span class="body3">Invoice Reports</span> </p>
          <p class="body2"><strong>Outlet sales<br />
            </strong>Outlet sales/turnover</p>
          <p class="body2"><strong>Diagnostic Report</strong> </p></td>
        <td width="610" valign="top"><form name="searchform" method="post" action="sales_to_outlets.php">
          <table id="nodisplay" width="610" height="213" dir="ltr">
            <tr>
              <td height="32" colspan="3" bgcolor="#558ED5"><span class="style37"> Sales to Outlet</span></td>
            </tr>
            <tr>
              <td style="padding-left:5px; padding-right:2px;" width="103" height="23" bgcolor="#E9EDF4" class="style35">From Date: </td>
              <td height="23" colspan="2" bgcolor="#E9EDF4" class="style35" style="padding-left:5px; padding-right:2px;">
		  
		  <?php if ($_POST['submit']) { ?>
		  <input name="from_date" type="text" id="from_date" value="<?= $_REQUEST['from_date']; ?>" />
              <? } else { ?>
		  <input name="from_date" type="text" id="from_date" value="<?= $rs_date_row['from_date_min']; ?>" /></td>
		  <? } ?>
		  
		  </tr>
            <tr>
              <td style="padding-left:5px; padding-right:2px;" height="23" bgcolor="#E9EDF4" class="style35">To Date: </td>
              <td height="23" colspan="2" bgcolor="#E9EDF4" class="style35" style="padding-left:5px; padding-right:2px;"><span class="style35">
                <?php if ($_POST['submit']) { ?>
			<input name="to_date" type="text" id="to_date" value="<?= $_REQUEST['to_date']; ?>" />				
              	<? } else { ?>
		  	<input name="to_date" type="text" id="to_date" value="<?= $rs_date_row['to_date_max'];?>" />
		   	<? } ?>
		   </span></td>
              </tr>
            <tr <?php if (is_int($i/2)) print "bgcolor=\"#558ED5\""; ?>>
              <td style="padding-left:5px; padding-right:2px;" height="23" bgcolor="#E9EDF4" class="style35">Region</td>
              <td height="23" colspan="2" bgcolor="#E9EDF4" class="style35" style="padding-left:5px; padding-right:2px;"><select name="region" id="region">
                  <option value="" selected="selected">All Areas</option>
                  <?php
			$sql_props = "SELECT * FROM $db.iStock";
			$result_props = mysql_query($sql_props) or die(error_report("Mysql Error", mysql_error()."\n\n$sql_props", $_SERVER['REMOTE_ADDR']));
			$area_list = array();

			while($rs_props = mysql_fetch_array($result_props))	{
				if (!in_array($rs_props['Venue_Area'], $area_list)) array_push($area_list, $rs_props['Venue_Area']);
			}
			asort($area_list);
	  	
			foreach($area_list as $area)	{
				print "<option value=\"".$area."\">".ucwords($area)."</option>";
			}
	  	?>
                </select>
                 </td>
            </tr>
            <tr <?php if (is_int($i/2)) print "bgcolor=\"#558ED5\""; ?>>
              <td style="padding-left:5px; padding-right:2px;" height="23" bgcolor="#E9EDF4" class="style35">Representative</td>
              <td height="23" colspan="2" bgcolor="#E9EDF4" class="style35" style="padding-left:5px; padding-right:2px;">
		  
		  <select name="reps">
                  <option selected="selected" value="%">All Reps</option>
                  <?php

			$sql_props = "SELECT * FROM $db.iStock";

			$result_props = mysql_query($sql_props) or die(error_report("Mysql Error", mysql_error()."\n\n$sql_props", $_SERVER['REMOTE_ADDR']));
			$area_list = array();

			while($rs_props = mysql_fetch_array($result_props))	{
				if (!in_array($rs_props['TMR_Name'], $area_list)) array_push($area_list, $rs_props['TMR_Name']);
			}
			asort($area_list);
	  	
			foreach($area_list as $area)	{
				print "<option value=\"".$area."\">".ucwords($area)."</option>";
			}
	  	?>
                </select>
		 </td>
            </tr>
            <tr <?php if (is_int($i/2)) print "bgcolor=\"#558ED5\""; ?>>
              <td style="padding-left:5px; padding-right:2px;" height="23" bgcolor="#E9EDF4" class="style35">Outlet</td>
              <td height="23" colspan="2" bgcolor="#E9EDF4" class="style35" style="padding-left:5px; padding-right:2px;"><select name="outlets" id="outlets">
                  <option value="" selected="selected">All Outlets</option>
                  <?php
			$sql_props = "SELECT * FROM $db.iStock";
			$result_props = mysql_query($sql_props) or die(error_report("Mysql Error", mysql_error()."\n\n$sql_props", $_SERVER['REMOTE_ADDR']));
			$area_list = array();

			while($rs_props = mysql_fetch_array($result_props))	{
				if (!in_array($rs_props['Venue_Name'], $area_list)) array_push($area_list, $rs_props['Venue_Name']);
			}
			asort($area_list);
	  	
			foreach($area_list as $area)	{
				print "<option value=\"".$area."\">".ucwords($area)."</option>";
			}
	  	?>
                </select>              </td>
            </tr>
            <tr <?php if (is_int($i/2)) print "bgcolor=\"#558ED5\""; ?>>
              <td style="padding-left:5px; padding-right:2px;" height="23" bgcolor="#E9EDF4" class="style35">Output Media </td>
              <td height="23" bgcolor="#E9EDF4" class="style35" style="padding-left:5px; padding-right:2px;"><a href="javascript:window.print()">Print Report</a> </td>
              <td width="342" height="23" bgcolor="#E9EDF4" class="style35" style="padding-left:5px; padding-right:2px;"><a href="3">Excel Download</a> </td>
            </tr>
            <tr>
              <td height="23" colspan="3" bgcolor="#D0D8E8"><input name="submit" type="submit" id="submit" value="Submit" /></td>
            </tr>
          </table>
                  </form>
          <? if (($from_date = $_REQUEST['from_date']) || ($to_date = $_REQUEST['to_date'])) { ?>
	  
	  <p class="body3"><strong>Report Generated:</strong> From <span class="style10">
            <?= $_REQUEST['from_date']; ?>
          </span> to <span class="style10">
          <?= $_REQUEST['to_date']; ?>
          </span><br />
          <strong>Representative:</strong> <span class="style10">
          <?= $_REQUEST['reps']; ?>
          </span><br />
	  </p>
	  <? } ?>
          <table width="610" height="144" dir="ltr">
            <tr>
              <td width="56" height="32" bgcolor="#558ED5"><span class="style37"> Rep</span></td>
              <td width="102" height="32" bgcolor="#558ED5"><span class="style37"> Outlet</span></td>
              <td height="32" bgcolor="#558ED5"><span class="style37"> Sales to Date</span></td>
              <td height="32" colspan="4" bgcolor="#558ED5"><div align="right"><span class="style37"> <span class="body-text"> Displaying
                <?= $numrows;?>
                records 
                  </span></span></div></td>
            </tr>
            <tr>
              <td width="56" height="29" bgcolor="#558ED5"><span class="style35"></span></td>
              <td width="102" height="29" bgcolor="#558ED5"><span class="style35"></span></td>
              <td width="139" height="29" bgcolor="#558ED5"><span class="style34"> Var</span></td>
              <td width="71" height="29" bgcolor="#558ED5"><div align="center"><span class="style34">Total Packs purchased<br />
                since installation</span></div></td>
              <td width="69" height="29" bgcolor="#558ED5"><div align="center"><span class="style34">Total<br />
                income generated</span></div></td>
              <td width="65" height="29" bgcolor="#558ED5"><div align="center"><span class="style34">Ave purchased per month</span></div></td>
              <td width="76" height="29" bgcolor="#558ED5" class="body"><div align="center">Total <br />
                monthly <br />
                income <br />
                generated </div></td>
            </tr>
            <?php
		$i = 0;
		while ($rs_prop = mysql_fetch_array($result_prop))	{
	?>
            <tr <?php if (is_int($i/2)) print "bgcolor=\"#558ED5\""; ?>>
              <td style="padding-left:5px; padding-right:2px;" width="56" height="23" bgcolor="#E9EDF4" class="style35"><span class="style10">
                <?= ucwords($rs_prop["TMR_Name"]); ?>
              </span></td>
              <td style="padding-left:5px; padding-right:2px;" width="102" height="23" bgcolor="#E9EDF4" class="style35"><span class="style10">
                <?= ucwords($rs_prop["Venue_Name"]); ?>
              </span></td>
              <td style="padding-left:5px; padding-right:2px;" width="139" height="23" bgcolor="#E9EDF4" class="style35"><span class="style10">
                <?= ucwords($rs_prop["L_Code_Code"]); ?>
              </span></td>
              <td width="71" height="23" bgcolor="#E9EDF4" class="style35"><div align="center"><span class="style10">
                  <?= ucwords($rs_prop["Quantity"]); ?>
              </span></div></td>
              <td width="69" height="23" bgcolor="#E9EDF4" class="style35"><div align="center"><span class="style10">R
                      <?= ucwords($rs_prop["Income"]); ?>
              </span></div></td>
              <td width="65" height="23" bgcolor="#E9EDF4" class="style35"><div align="center"><span class="style10">
                  <?= ucwords($rs_prop["Purchased"]); ?>
              </span></div></td>
              <td height="23" bgcolor="#E9EDF4" class="style35"><div align="center">R
                    <?= ucwords($rs_prop["Month_Income"]); ?>
              </div></td>
            </tr>
            <?php $i++; } ?>

            <tr>
              <td height="23" colspan="3" bgcolor="#D0D8E8" class="body"><div align="right"><strong>Totals:  </strong></div></td>
              <td height="23" bgcolor="#D0D8E8" class="style35"><div align="center">
                  <?= $rs_prop2['total_quantity']; ?>
                  </span></div></td>
              <td height="23" bgcolor="#D0D8E8" class="style35"><div align="center"> R
                    <?= $rs_prop2['total_income']; ?>
              </div></td>
              <td height="23" bgcolor="#D0D8E8" class="style35"><div align="center">
                  <?= $rs_prop2['total_purchased']; ?>
              </div></td>
              <td height="23" bgcolor="#D0D8E8" class="style35"><div align="center"> R
                    <?= $rs_prop2['total_month_income']; ?>
              </div></td>
            </tr>
            <tr>
              <td height="23" colspan="7" bgcolor="#D0D8E8"><div align="right" class="body3">  </div></td>
            </tr>
          </table>
          <p> </p></td>
      </tr>
    </table></td>
  </tr>
</table>
<p> </p>
</body>
</html>
<script>
<?php
function dropdown($values, $form)	{
	foreach($values as $key => $value)	{
		print "document.".$form.".".$key.".value = \"".$value."\";\n";
		$i++;
	}
}

if (eregi($_SERVER['PHP_SELF'], $_SERVER['HTTP_REFERER']))	{
	$dropdown['reps'] = $_POST['reps'];
	//$dropdown['status'] = $_POST['status'];
	//$dropdown['Status'] = $_POST['Status'];
	$validate->dropdown($dropdown, "searchform");
}
?>
//ddType(document.searchform.type);
</script>

 

Link to comment
https://forums.phpfreaks.com/topic/73457-display-all-records/
Share on other sites

  • 2 weeks later...

try this, your get the idea (review code below)

 

<?php
// includes
include("../inc/conn.inc.php");
include("../inc/validate.inc.php");
?>
<?php

$from_date = $_REQUEST['from_date'];
$to_date = $_REQUEST['to_date'];

if ($_POST['submit']) {

	$REPS="";
	if($_REQUEST['reps'] != "")
	{
		$REPS = "AND TMR_Name = '".$_REQUEST['reps']."' ";
	}

	$sql_prop = "SELECT * FROM $db.iStock WHERE Trans_Date BETWEEN '".$from_date."' AND '".$to_date."' $REPS ORDER BY Trans_Date ASC";
	$result_prop = mysql_query($sql_prop);

	$sql_date = "SELECT * FROM $db.iStock WHERE Trans_Date BETWEEN '".$from_date."' AND '".$to_date."' $REPS ORDER BY Trans_Date ASC";
	$result_date = mysql_query($sql_date);
	$rs_date = mysql_fetch_array($result_date);

	//summation
	$sql_prop2 ="SELECT SUM(Quantity) AS total_quantity, SUM(Income) AS total_income, SUM(Purchased) AS total_purchased, SUM(Month_Income) AS total_month_income FROM $db.iStock WHERE Trans_Date BETWEEN '".$from_date."' AND '".$to_date."' $REPS ORDER BY Venue_Name ASC";
	$result_prop2 = mysql_query($sql_prop2) or die(error_report("Mysql Error", mysql_error()."\n\n$sql_rows", $_SERVER['REMOTE_ADDR']));
	$rs_prop2 = mysql_fetch_array($result_prop2);
	////

	$sql_rows = "SELECT COUNT(*) FROM $db.iStock WHERE Trans_Date BETWEEN '".$from_date."' AND '".$to_date."' $REPS";
	$result_rows = mysql_query($sql_rows);
	$rs_rows = mysql_fetch_array($result_rows);
	$numrows = $rs_rows[0];	




} else {
  		$sql_prop="SELECT * FROM $db.iStock ORDER BY Venue_Name ASC";
	$result_prop = mysql_query($sql_prop) or die(error_report("Mysql Error", mysql_error()."\n\n$sql_rows", $_SERVER['REMOTE_ADDR']));

	//summation
	$sql_prop2 ="SELECT SUM(Quantity) AS total_quantity, SUM(Income) AS total_income, SUM(Purchased) AS total_purchased, SUM(Month_Income) AS total_month_income FROM $db.iStock ORDER BY Venue_Name ASC";
	$result_prop2 = mysql_query($sql_prop2) or die(error_report("Mysql Error", mysql_error()."\n\n$sql_rows", $_SERVER['REMOTE_ADDR']));
	$rs_prop2 = mysql_fetch_array($result_prop2);
	/////

	$sql_rows = "SELECT COUNT(*) FROM $db.iStock ORDER BY Venue_Name ASC";
	$result_rows = mysql_query($sql_rows) or die(error_report("Mysql Error", mysql_error()."\n\n$sql_rows", $_SERVER['REMOTE_ADDR']));
	$rs_rows = mysql_fetch_array($result_rows);
	$numrows = $rs_rows[0];	

	$sql_date_row ="SELECT MAX(Trans_Date) AS to_date_max, MIN(Trans_Date) AS from_date_min FROM $db.iStock";
	$result_date_row = mysql_query($sql_date_row);
	$rs_date_row = mysql_fetch_array($result_date_row);


	}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>

<link href="../styles/opus_db.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style39 {font-size: 24px}
.style41 {font-size: 12px; padding-left: 10px; font-family: Arial, Helvetica, sans-serif;}
.style42 {color: #558ED5}
-->
</style>
<link href="../styles/opus_db_print.css" media="print" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="778" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#BECADE">
  <tr>
    <td valign="middle"><p align="right" class="head1"><br />
      <span class="style39"> iStock Online  </span></p>
     
  <table width="782" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
      <!--DWLayoutTable-->
      <tr>
        <td id="nodisplay" width="172" height="299" valign="top" bgcolor="#E9EDF4"><p class="head2"><strong> <u>Menu</u> </strong></p>
            <p class="body2"><strong>Online stock management<br />
              </strong><a href="alerts.php" style="color:#000000"><span class="style41">Alerts</span></a><br />
              <span class="body3"><a href="current_outlet.php" style="color:#000000;">Current Outlet stock bal</a></span><br />
              <a href="sales.php"><span class="body3 " style="color:#000000">Sales to date</span></a><br />
            <span class="body3"><a href="model.php" style="color:#000000">Model stock settings</a></span></p>
          <p class="body2"><strong>Management Reports<br />
              </strong><span class="body3 style42"><strong>Sales to Outlets</strong></span><br />
              <span class="body3">Sales by SKU</span><br />
              <span class="body3">Monthly report</span><br />
              <span class="body3">Rep Monthly Report</span><br />
            <span class="body3">Invoice Reports</span> </p>
          <p class="body2"><strong>Outlet sales<br />
            </strong>Outlet sales/turnover</p>
          <p class="body2"><strong>Diagnostic Report</strong> </p></td>
        <td width="610" valign="top"><form name="searchform" method="post" action="sales_to_outlets.php">
          <table id="nodisplay" width="610" height="213" dir="ltr">
            <tr>
              <td height="32" colspan="3" bgcolor="#558ED5"><span class="style37"> Sales to Outlet</span></td>
            </tr>
            <tr>
              <td style="padding-left:5px; padding-right:2px;" width="103" height="23" bgcolor="#E9EDF4" class="style35">From Date: </td>
              <td height="23" colspan="2" bgcolor="#E9EDF4" class="style35" style="padding-left:5px; padding-right:2px;">
		  
		  <?php if ($_POST['submit']) { ?>
		  <input name="from_date" type="text" id="from_date" value="<?= $_REQUEST['from_date']; ?>" />
              <? } else { ?>
		  <input name="from_date" type="text" id="from_date" value="<?= $rs_date_row['from_date_min']; ?>" /></td>
		  <? } ?>
		  
		  </tr>
            <tr>
              <td style="padding-left:5px; padding-right:2px;" height="23" bgcolor="#E9EDF4" class="style35">To Date: </td>
              <td height="23" colspan="2" bgcolor="#E9EDF4" class="style35" style="padding-left:5px; padding-right:2px;"><span class="style35">
                <?php if ($_POST['submit']) { ?>
			<input name="to_date" type="text" id="to_date" value="<?= $_REQUEST['to_date']; ?>" />				
              	<? } else { ?>
		  	<input name="to_date" type="text" id="to_date" value="<?= $rs_date_row['to_date_max'];?>" />
		   	<? } ?>
		   </span></td>
              </tr>
            <tr <?php if (is_int($i/2)) print "bgcolor=\"#558ED5\""; ?>>
              <td style="padding-left:5px; padding-right:2px;" height="23" bgcolor="#E9EDF4" class="style35">Region</td>
              <td height="23" colspan="2" bgcolor="#E9EDF4" class="style35" style="padding-left:5px; padding-right:2px;"><select name="region" id="region">
                  <option value="" selected="selected">All Areas</option>
                  <?php
			$sql_props = "SELECT * FROM $db.iStock";
			$result_props = mysql_query($sql_props) or die(error_report("Mysql Error", mysql_error()."\n\n$sql_props", $_SERVER['REMOTE_ADDR']));
			$area_list = array();

			while($rs_props = mysql_fetch_array($result_props))	{
				if (!in_array($rs_props['Venue_Area'], $area_list)) array_push($area_list, $rs_props['Venue_Area']);
			}
			asort($area_list);
	  	
			foreach($area_list as $area)	{
				print "<option value=\"".$area."\">".ucwords($area)."</option>";
			}
	  	?>
                </select>
                 </td>
            </tr>
            <tr <?php if (is_int($i/2)) print "bgcolor=\"#558ED5\""; ?>>
              <td style="padding-left:5px; padding-right:2px;" height="23" bgcolor="#E9EDF4" class="style35">Representative</td>
              <td height="23" colspan="2" bgcolor="#E9EDF4" class="style35" style="padding-left:5px; padding-right:2px;">
		  
		  <select name="reps">
                  <option selected="selected" value="%">All Reps</option>
                  <?php

			$sql_props = "SELECT * FROM $db.iStock";

			$result_props = mysql_query($sql_props) or die(error_report("Mysql Error", mysql_error()."\n\n$sql_props", $_SERVER['REMOTE_ADDR']));
			$area_list = array();

			while($rs_props = mysql_fetch_array($result_props))	{
				if (!in_array($rs_props['TMR_Name'], $area_list)) array_push($area_list, $rs_props['TMR_Name']);
			}
			asort($area_list);
	  	
			foreach($area_list as $area)	{
				print "<option value=\"".$area."\">".ucwords($area)."</option>";
			}
	  	?>
                </select>
		 </td>
            </tr>
            <tr <?php if (is_int($i/2)) print "bgcolor=\"#558ED5\""; ?>>
              <td style="padding-left:5px; padding-right:2px;" height="23" bgcolor="#E9EDF4" class="style35">Outlet</td>
              <td height="23" colspan="2" bgcolor="#E9EDF4" class="style35" style="padding-left:5px; padding-right:2px;"><select name="outlets" id="outlets">
                  <option value="" selected="selected">All Outlets</option>
                  <?php
			$sql_props = "SELECT * FROM $db.iStock";
			$result_props = mysql_query($sql_props) or die(error_report("Mysql Error", mysql_error()."\n\n$sql_props", $_SERVER['REMOTE_ADDR']));
			$area_list = array();

			while($rs_props = mysql_fetch_array($result_props))	{
				if (!in_array($rs_props['Venue_Name'], $area_list)) array_push($area_list, $rs_props['Venue_Name']);
			}
			asort($area_list);
	  	
			foreach($area_list as $area)	{
				print "<option value=\"".$area."\">".ucwords($area)."</option>";
			}
	  	?>
                </select>              </td>
            </tr>
            <tr <?php if (is_int($i/2)) print "bgcolor=\"#558ED5\""; ?>>
              <td style="padding-left:5px; padding-right:2px;" height="23" bgcolor="#E9EDF4" class="style35">Output Media </td>
              <td height="23" bgcolor="#E9EDF4" class="style35" style="padding-left:5px; padding-right:2px;"><a href="javascript:window.print()">Print Report</a> </td>
              <td width="342" height="23" bgcolor="#E9EDF4" class="style35" style="padding-left:5px; padding-right:2px;"><a href="3">Excel Download</a> </td>
            </tr>
            <tr>
              <td height="23" colspan="3" bgcolor="#D0D8E8"><input name="submit" type="submit" id="submit" value="Submit" /></td>
            </tr>
          </table>
                  </form>
          <? if (($from_date = $_REQUEST['from_date']) || ($to_date = $_REQUEST['to_date'])) { ?>
	  
	  <p class="body3"><strong>Report Generated:</strong> From <span class="style10">
            <?= $_REQUEST['from_date']; ?>
          </span> to <span class="style10">
          <?= $_REQUEST['to_date']; ?>
          </span><br />
          <strong>Representative:</strong> <span class="style10">
          <?= $_REQUEST['reps']; ?>
          </span><br />
	  </p>
	  <? } ?>
          <table width="610" height="144" dir="ltr">
            <tr>
              <td width="56" height="32" bgcolor="#558ED5"><span class="style37"> Rep</span></td>
              <td width="102" height="32" bgcolor="#558ED5"><span class="style37"> Outlet</span></td>
              <td height="32" bgcolor="#558ED5"><span class="style37"> Sales to Date</span></td>
              <td height="32" colspan="4" bgcolor="#558ED5"><div align="right"><span class="style37"> <span class="body-text"> Displaying
                <?= $numrows;?>
                records 
                  </span></span></div></td>
            </tr>
            <tr>
              <td width="56" height="29" bgcolor="#558ED5"><span class="style35"></span></td>
              <td width="102" height="29" bgcolor="#558ED5"><span class="style35"></span></td>
              <td width="139" height="29" bgcolor="#558ED5"><span class="style34"> Var</span></td>
              <td width="71" height="29" bgcolor="#558ED5"><div align="center"><span class="style34">Total Packs purchased<br />
                since installation</span></div></td>
              <td width="69" height="29" bgcolor="#558ED5"><div align="center"><span class="style34">Total<br />
                income generated</span></div></td>
              <td width="65" height="29" bgcolor="#558ED5"><div align="center"><span class="style34">Ave purchased per month</span></div></td>
              <td width="76" height="29" bgcolor="#558ED5" class="body"><div align="center">Total <br />
                monthly <br />
                income <br />
                generated </div></td>
            </tr>
            <?php
		$i = 0;
		while ($rs_prop = mysql_fetch_array($result_prop))	{
	?>
            <tr <?php if (is_int($i/2)) print "bgcolor=\"#558ED5\""; ?>>
              <td style="padding-left:5px; padding-right:2px;" width="56" height="23" bgcolor="#E9EDF4" class="style35"><span class="style10">
                <?= ucwords($rs_prop["TMR_Name"]); ?>
              </span></td>
              <td style="padding-left:5px; padding-right:2px;" width="102" height="23" bgcolor="#E9EDF4" class="style35"><span class="style10">
                <?= ucwords($rs_prop["Venue_Name"]); ?>
              </span></td>
              <td style="padding-left:5px; padding-right:2px;" width="139" height="23" bgcolor="#E9EDF4" class="style35"><span class="style10">
                <?= ucwords($rs_prop["L_Code_Code"]); ?>
              </span></td>
              <td width="71" height="23" bgcolor="#E9EDF4" class="style35"><div align="center"><span class="style10">
                  <?= ucwords($rs_prop["Quantity"]); ?>
              </span></div></td>
              <td width="69" height="23" bgcolor="#E9EDF4" class="style35"><div align="center"><span class="style10">R
                      <?= ucwords($rs_prop["Income"]); ?>
              </span></div></td>
              <td width="65" height="23" bgcolor="#E9EDF4" class="style35"><div align="center"><span class="style10">
                  <?= ucwords($rs_prop["Purchased"]); ?>
              </span></div></td>
              <td height="23" bgcolor="#E9EDF4" class="style35"><div align="center">R
                    <?= ucwords($rs_prop["Month_Income"]); ?>
              </div></td>
            </tr>
            <?php $i++; } ?>

            <tr>
              <td height="23" colspan="3" bgcolor="#D0D8E8" class="body"><div align="right"><strong>Totals:  </strong></div></td>
              <td height="23" bgcolor="#D0D8E8" class="style35"><div align="center">
                  <?= $rs_prop2['total_quantity']; ?>
                  </span></div></td>
              <td height="23" bgcolor="#D0D8E8" class="style35"><div align="center"> R
                    <?= $rs_prop2['total_income']; ?>
              </div></td>
              <td height="23" bgcolor="#D0D8E8" class="style35"><div align="center">
                  <?= $rs_prop2['total_purchased']; ?>
              </div></td>
              <td height="23" bgcolor="#D0D8E8" class="style35"><div align="center"> R
                    <?= $rs_prop2['total_month_income']; ?>
              </div></td>
            </tr>
            <tr>
              <td height="23" colspan="7" bgcolor="#D0D8E8"><div align="right" class="body3">  </div></td>
            </tr>
          </table>
          <p> </p></td>
      </tr>
    </table></td>
  </tr>
</table>
<p> </p>
</body>
</html>
<script>
<?php
function dropdown($values, $form)	{
	foreach($values as $key => $value)	{
		print "document.".$form.".".$key.".value = \"".$value."\";\n";
		$i++;
	}
}

if (eregi($_SERVER['PHP_SELF'], $_SERVER['HTTP_REFERER']))	{
	$dropdown['reps'] = $_POST['reps'];
	//$dropdown['status'] = $_POST['status'];
	//$dropdown['Status'] = $_POST['Status'];
	$validate->dropdown($dropdown, "searchform");
}
?>
//ddType(document.searchform.type);
</script>

 

Link to comment
https://forums.phpfreaks.com/topic/73457-display-all-records/#findComment-379221
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.