All pastes #759475 Raw Edit

Mine

public text v1 · immutable
·published 2007-11-03 04:18 UTC
rendered paste body
<html>
<head>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
</head>
<?php
/**
* $file_name = 'ghost_license.csv';
* header('Content-Type: text/comma-separated-values');
* //IE need specific header...
* if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
* {
* header('Content-Disposition: attachment; filename="'.$file_name.'"');
* header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
* header('Pragma: public');
* }
* else
* {
* header('Content-Disposition: attachment;
* filename="'.$file_name.'"');
* header('Pragma: no-cache');
* }
*/require_once( '../../Connections/ghostlicense.php' );
require_once( '../../Connections/Shopping.php' );
mysql_select_db( $database_Shopping, $Shopping );
$query_Ghost_Hunt_Dates = "SELECT CubeCart_inventory.name FROM CubeCart_inventory WHERE CubeCart_inventory.cat_id =6 ORDER BY CubeCart_inventory.productId";
$Ghost_Hunt_Dates = mysql_query( $query_Ghost_Hunt_Dates, $Shopping ) or die( mysql_error() );
$row_Ghost_Hunt_Dates = mysql_fetch_assoc( $Ghost_Hunt_Dates );
$totalRows_Ghost_Hunt_Dates = mysql_num_rows( $Ghost_Hunt_Dates );

mysql_select_db( $database_ghostlicense, $ghostlicense );

/*
Work out which page is being viewed, and thus the 'LIMIT page, numberPerPage' query extension.
*/


$numberPerPage = 20;
$pageNumber = ( isset($_REQUEST['pageNumber']) ? (int) $_REQUEST['pageNumber'] : 1 );
assert('$pageNumber > 0');
$pageLimitClause = " LIMIT ".($pageNumber-1)*$numberPerPage.", ".$pageNumber*$numberPerPage;

/*
if ( isset( $_GET['order'] ) ) {
				$query_Tour_Date = "SELECT * FROM license ORDER BY " . $_GET['order'];
				$result = mysql_query( $query_Tour_Date ) or die( mysql_error() );
				$Tour_Date = mysql_query( $query_Tour_Date.$pageLimitClause, $ghostlicense ) or die( mysql_error() );
				$row_Tour_Date = mysql_fetch_assoc( $Tour_Date );
				$num_rows = mysql_num_rows($result );
				} else {
				$query_Tour_Date = "SELECT * FROM license ORDER BY Last_Name";
				$result = mysql_query( $query_Tour_Date ) or die( mysql_error() );
				$Tour_Date = mysql_query( $query_Tour_Date.$pageLimitClause, $ghostlicense ) or die( mysql_error() );
				$row_Tour_Date = mysql_fetch_assoc( $Tour_Date );
				$num_rows = mysql_num_rows( $result );
				} 

if ( isset( $_REQUEST['fGhost_Hunt'] ) ) {
				if ( $fGhost_Hunt == 'all' ) {
								$filter_Tour_Date = "SELECT * FROM license ORDER BY Last_Name";
								$result = mysql_query( $filter_Tour_Date ) or die( mysql_error() );
								$Tour_Date = mysql_query( $filter_Tour_Date.$pageLimitClause, $ghostlicense ) or die( mysql_error() );
								$row_Tour_Date = mysql_fetch_assoc( $Tour_Date );
								$num_rows = mysql_num_rows( $result );
								} else {
								$filter_Tour_Date = "SELECT * FROM license WHERE Ghost_Hunt = '$fGhost_Hunt' ORDER BY Last_Name";
								$result = mysql_query( $filter_Tour_Date ) or die( mysql_error() );
								$Tour_Date = mysql_query( $filter_Tour_Date.$pageLimitClause, $ghostlicense ) or die( mysql_error() );
								$row_Tour_Date = mysql_fetch_assoc( $Tour_Date );
								$num_rows = mysql_num_rows( $result );
								} 
				} 
				*/
				
if ( isset( $_GET['order']) & isset( $_REQUEST['fGhost_Hunt']  ) ) {
                                if ( $fGhost_Hunt == 'all' ) {
                                                             $query_Tour_Date = "SELECT * FROM license ORDER BY " . $_GET['order'];
                                }else{
                                $query_Tour_Date = "SELECT * FROM license WHERE Ghost_Hunt = '$fGhost_Hunt' ORDER BY " . $_GET['order'];
                                }
                             }elseif(
     !isset($_GET['order']) & isset( $_REQUEST['fGhost_Hunt'] ) ){
                                if ( $fGhost_Hunt == 'all' ) {
                                                             $query_Tour_Date = "SELECT * FROM license ORDER BY Last_Name";
                                }else{
                                $query_Tour_Date = "SELECT * FROM license WHERE Ghost_Hunt = '$fGhost_Hunt' ORDER BY Last_Name";
                                }
                             }elseif(
     isset($_GET['order']) & !isset( $_REQUEST['fGhost_Hunt'] ) ){
                                                             $query_Tour_Date = "SELECT * FROM license ORDER BY " . $_GET['order'];
                             }else{
                                                             $query_Tour_Date = "SELECT * FROM license ORDER BY Last_Name";
                                }
                $result = mysql_query( $query_Tour_Date ) or die( mysql_error() );
				$Tour_Date = mysql_query( $query_Tour_Date.$pageLimitClause, $ghostlicense ) or die( mysql_error() );
				$row_Tour_Date = mysql_fetch_assoc( $Tour_Date );
				$num_rows = mysql_num_rows($result );				
				
if ( $_POST['export'] ) {
                if ( $fGhost_Hunt == 'all' ) {
				$query_Tour_Date = "SELECT * FROM license ORDER BY Last_Name";
				}else{
                $query_Tour_Date = "SELECT * FROM license WHERE Ghost_Hunt ='".$fGhost_Hunt."' ORDER BY Last_Name";
				}
				$result = mysql_query( $query_Tour_Date ) or die( mysql_error() );
				function xlsBOF()
				{
								 echo pack( "ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0 );
								 return;
								} 
				
				function xlsEOF()
				{
								 echo pack( "ss", 0x0A, 0x00 );
								 return;
								} 
				
				function xlsWriteNumber( $Row, $Col, $Value )
				{
								 echo pack( "sssss", 0x203, 14, $Row, $Col, 0x0 );
								 echo pack( "d", $Value );
								 return;
								} 
				
				function xlsWriteLabel( $Row, $Col, $Value )
				{
								 $L = strlen( $Value );
								 echo pack( "ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L );
								 echo $Value;
								return;
								} 
				$file_name = 'ghost_license.xls';
				 header( "Pragma: public" );
				 header( "Expires: 0" );
				 header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
				 header( "Content-Type: application/force-download" );
				 header( "Content-Type: application/octet-stream" );
				 header( "Content-Type: application/download" );
				 header( 'Content-Disposition: attachment; filename="' . $file_name . '"' );
				 header( "Content-Transfer-Encoding: binary " );
				// XLS Data Cell
				 xlsBOF();
				 xlsWriteLabel( 0, 0, "First Name" );
				 xlsWriteLabel( 0, 1, "Last Name" );
				 xlsWriteLabel( 0, 2, "Address" );
				 xlsWriteLabel( 0, 3, "City" );
				 xlsWriteLabel( 0, 4, "State" );
				 xlsWriteLabel( 0, 5, "Zip Code" );
				 $xlsRow = 1;

				 while ( list( $ID, $First_Name, $Last_Name, $Address, $City, $State, $Zip_Code ) = mysql_fetch_row( $result ) ) {
				  $string1 = "'";
				  $string2 = "/";
								++$i;
								 xlsWriteLabel( $xlsRow, 0, strtoupper("$First_Name"));
								 xlsWriteLabel( $xlsRow, 1, strtoupper("$Last_Name"));
								 xlsWriteLabel( $xlsRow, 2, strtoupper("$Address") );
								 xlsWriteLabel( $xlsRow, 3, strtoupper("$City") );
								 xlsWriteLabel( $xlsRow, 4, strtoupper("$State") );
								 xlsWriteLabel( $xlsRow, 5, "$Zip_Code" );
								 $xlsRow++;
								 } 
				xlsEOF();
				 exit();
				
				 // print($expData);
				// exit;
} 
?>
<body>
<div align="center">
  <!-- ******** BEGIN CODE FOR menu ******** -->
  <script type='text/javascript'>
var MenuLinkedBy='AllWebMenus [4]',
awmMenuName='menu',
awmBN='DW';awmAltUrl='';
</script>
  <script charset='UTF-8' src='menu.js' type='text/javascript'></script>
  <script type='text/javascript'>awmBuildMenu();</script>
  <!-- ******** END CODE FOR menu ******** -->
  <style type="text/css">
body {
	background-color:#FFFFD5;
}
FORM {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #000080;
border: 2px solid #4682B4;
padding: 5px;
background-color: #0099CC;
}
table {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #000080;
border-color: #0066CC;
background-color: #0099CC;
}
td {
font-size:10px;
background-color:#FFFFCC;
}
</style>
  <span id='awmAnchor-menu'></span>
  <br>
  <br>
  <br>
</div>
<p></p>
<form id="filter" name="filter" method="post" action="<?php echo "ghost_license.php?filter='" . $fGhost_Hunt . "'";
?>">

<table border="0" cellspacing="5" cellpadding="5">
<tr>
<td>

      <select name="fGhost_Hunt">
	  <option name="Ghost Hunt" value='all'>All Ghost Hunts</option>
        <?php
do {
				?>

        <option name="Ghost_Hunt" value="<?php echo $row_Ghost_Hunt_Dates['name']?>"><?php echo $row_Ghost_Hunt_Dates['name']?></option>
        <?php
				} while ( $row_Ghost_Hunt_Dates = mysql_fetch_assoc( $Ghost_Hunt_Dates ) );
 $rows = mysql_num_rows( $Ghost_Hunt_Dates );
?>
      </select>
</td>
<td><input type="submit"  value="Filter" name="filter"></td>
<td><input type="submit"  value="Make Labels" name="export"></td>
<td border=2   style="font-size:14px" style="font-weight:bold">Total Records = <?php echo $num_rows ;
?></td>
<td>
<?php
/*
Print the page traverse links. Remember to preserve the current filter
*/
$numberOfPages = ceil($num_rows / $numberPerPage);

$traverseLinks = array( 'First'=>1, 'Previous'=>($pageNumber == 1 ? 1 : $pageNumber-1), 
		'Next'=>($pageNumber == $numberOfPages ? $numberOfPages : $pageNumber+1), 'Last'=> $numberOfPages);

foreach($traverseLinks as $name => $page)
{
	print '<a href="ghost_license.php?'.( isset($fGhost_Hunt) ? 'fGhost_Hunt='.urlencode($fGhost_Hunt).'&' : '' ).'pageNumber='.$page.'">'.$name.'</a> ';
}

?>
</td>
<td>
<?php
print 'Viewing page '.$pageNumber.' of '.$numberOfPages;
?>
</td>
<td>
&nbsp;</td>
</tr>
</table>
</form>
<?php
$menu_background = "awmdata/main-button-tile.gif";
?>
<form>
<table border="1">
  <tr>
    <td background="<?php echo $menu_background;
?>"><img src="edit.png"></td>
    <td background="<?php echo $menu_background;
?>"><a href="ghost_license.php?order=ID&fGhost_Hunt='<?php echo $fGhost_Hunt;?>'">ID</a></td>
    <td background="<?php echo $menu_background;
?>"><a href="ghost_license.php?order=Last_Name">Last_Name</a></td>
    <td background="<?php echo $menu_background; 
?>"><a href="ghost_license.php?order=First_Name">First_Name</a></td>
    <td background="<?php echo $menu_background;
?>"><a href="ghost_license.php?order=Address">Address</a></td><td background="<?php echo $menu_background;
?>"><a href="ghost_license.php?order=City">City</a></td>
    <td background="<?php echo $menu_background;
?>"><a href="ghost_license.php?order=State">State</a></td>
    <td background="<?php echo $menu_background;
?>"><a href="ghost_license.php?order=Zip_Code">Zip_Code</a></td>
    <td background="<?php echo $menu_background;
?>"><a href="ghost_license.php?order=Phone">Phone</a></td>
    <td background="<?php echo $menu_background;
?>"><a href="ghost_license.php?order=EMail">EMail</a></td>
    <td background="<?php echo $menu_background;
?>"><a href="ghost_license.php?order=Date">Date</a></td>
    <td background="<?php echo $menu_background;
?>"><a href="ghost_license.php?order=Ghost_Hunt">Ghost_Hunt</a></td>
	<td background="<?php echo $menu_background;
?>"><a href="ghost_license.php?order=Comments">Comments</a></td>
	<td background="<?php echo $menu_background;
?>"><a href="ghost_license.php?order=People_Attending">People Attending</a></td>
  </tr>
  <?php do {
				?>
    <tr>
	  <td><a href="edit_ghost_license.php?id=<?php echo $row_Tour_Date['ID'];
				?>"><img border=0 src="edit.png"></a></td>
      <td><?php echo $row_Tour_Date['ID'];
				?></td>
      <td><?php echo $row_Tour_Date['Last_Name'];
				?></td>
      <td><?php echo $row_Tour_Date['First_Name'];
				?></td>
      <td><?php echo $row_Tour_Date['Address'];
				?></td>
      <td><?php echo $row_Tour_Date['City'];
				?></td>
      <td><?php echo $row_Tour_Date['State'];
				?></td>
      <td><?php echo $row_Tour_Date['Zip_Code'];
				?></td>
      <td><?php echo $row_Tour_Date['Phone'];
				?></td>
      <td><?php echo $row_Tour_Date['EMail'];
				?></td>
      <td><?php echo $row_Tour_Date['Date'];
				?></td>
      <td><?php echo $row_Tour_Date['Ghost_Hunt'];
				?></td>
      <td><?php echo $row_Tour_Date['Comments'];
				?></td>
	  <td><?php echo $row_Tour_Date['People_Attending'];
				?></td>
    </tr>
    <?php } while ( $row_Tour_Date = mysql_fetch_assoc( $Tour_Date ) );
?>
</table>
</form>
<p>
  <?php
mysql_free_result( $Tour_Date );
?>
</p>
</body>
</html>