All pastes #737476 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-10-15 13:44 UTC
rendered paste body
<?php



  function ShowMyFiles() {
  
    // vars global configuration
    global $dbConn, $theme_path;

    // vars messages
    global $msg;

    // vars template
    global $error_msg, $status, $files, $owner, $test, $paginated;
	
    if ($err) {
      $error_msg = 'Custom error message';
    }
    // get variable after selecting something from the dropdown with name 'chooser'
	$select = $_POST['select'];

	// if something has been chosen
	if (!empty($select)) {

	// get the chosen value
	$chooser = $_POST['chooser'];
	
	if(!isset($_GET['page'])){
    $page = 1;
	} else {
    $page = $_GET['page'];
	}
	// Define the number of results per page
	$max_results = 10;
	
	// Figure out the limit for the query based
	// on the current page number.
	$from = (($page * $max_results) - $max_results);
    
	

    // get file listing
    // if everything successful create query
	// this selects all rows where the type is the one you chose in the dropdown
	// * means that it will select all columns, ie name and type as i said above
	
	$sql = "SELECT * FROM idx_reslink WHERE category_id='$chooser' LIMIT $from, $max_results";
   	$result  = $dbConn->Execute($sql);
	
	// Figure out the total number of results in DB:
	$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM idx_reslink WHERE category_id='$chooser'"),0);
	
	// Figure out the total number of pages. Always round up using ceil()
	$lastpage = ceil($total_results / $max_results);
	
	global $paginated;
    $paginated .= "<center>Select a Page<br />";
    
    if ($page == 1) {
    $paginated .= " FIRST PREV ";
    } else {
       $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=1'>FIRST</a> ";
       $prevpage = $page-1;
       $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=$prevpage'>PREV</a> ";
    } 
    $paginated .= " ( Page $page of $lastpage ) ";
    
    if ($page == $lastpage) {
   $paginated .= " NEXT LAST ";
    } else {
   $nextpage = $page+1;
   $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=$nextpage'>NEXT</a> ";
   $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=$lastpage'>LAST</a> ";
    }
	
	$test = '';
   	for($i = 0;$i < $result->RecordCount(); $i++){
   	$file = $result->Fields("title");
   	$description = $result->Fields("description");
   	$date = $result->Fields("date");
   
   	$test .= '<table width="100%%"  border="0">
  	<tr>
    <td></td>
  	</tr>
	</table>

	<table cellpadding="2" cellspacing="1" border="0" align="center" width="100%" class="tbl_border_mem">
	<tr class="tbl_caption_mem">
  	<td width="12%"><strong>Title</strong></td>
  	<td width="73%"><strong>Description</strong></td>
  	<td width="15%"><strong>Date Added</strong></td>
	</tr>
	<tr class="tbl_caption_mem">
  	<td valign="top">'.$file.'</td>
  	<td valign="top">'.$description.'</td>
  	<td valign="top">'.$date.'</td>
  	</tr>
  	</table> <br />';
	
  	$result->movenext();}
  	}
  	$files = $test;
   		DisplayTemplate($theme_path . "cp/data.html", "\$files,\$paginated,\$error_msg");
  	}

  	/*===================================================
    main
  	===================================================*/

  	include "../application.php";

  	RunPreFilter(__FILE__);

  	ShowMyFiles();

  	RunPostFilter(__FILE__);

?>

//---------------------------html file---------------------------

<%include file="cp/header.html"
          title="Research File Area"
          meta_keywords=""
          meta_description=""
%>

    </td>
  </tr>
  <tr>
    <td>

    <!-- main content here -->

    <br />
    

    

    <%if $error_msg%>
    <center><p><font color="Red"><b><%$error_msg%></b></font></p></center>
    <%/if%>
    <%if $files%>
      <%$files%>
    <%else%>
      <div align="center">
      <p>No new System messages or downloads.</p></div>
    <%/if%><%$paginated%>
<!-- pagination -->
    
    <center>
    
    <br />
    <br />

    <!-- end of main content -->

    </td>
  </tr>
  <tr>
    <td>

<%include file="cp/footer.html"%>

//------------------------------------datadrop html 1st file-------------------------

<%include file="cp/header.html"
          title="Research File Area"
          meta_keywords=""
          meta_description=""
%>

<!-- This defines a new form -->
<form action="cp/data.php" method="post">

<!-- This creates the dropdown in html -->
<select name="chooser">

<option value="1">Yarmouth Passenger List</option>
<option value="2">Cambridge Parish Marriages #1</option>
<option value="3">Cambridge Parish Marriages #2</option>

</select>

<!-- Create a button -->
<input type="submit" value="Select" name="select">

</form> 

<%include file="cp/footer.html"%>