⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 results.php

📁 alumini based system
💻 PHP
字号:
<?
//connect to your database ** EDIT REQUIRED HERE **
mysql_connect("localhost","root",""); //(host, username, password)

//specify database ** EDIT REQUIRED HERE **
mysql_select_db("alumni") or die("Unable to select database"); //select which database we're using

  //delete alumni 
  if (isset($_GET['action']) && ($_GET['action']=="delete")){
     $msg="delete".$_GET['id'] ;
     $result=mysql_query("DELETE FROM ALUMNI WHERE user_index=".$_GET['id']);
  }
?>

<html>
<head>
<title>Spread your wings, but keep in touch!</title>
<meta name="author" content="Sudershan Thaiba, sudershanthaiba@gmail.com">
</head>
<body>
<center>
<img src=../banner.jpg>
<h1 color="red">Alumni ::: Keep in Touch</h1>
        <form method="get" action=<? $_SERVER['PHP_SELF'] ?>>
        <div align="center">
        <table border="0" cellpadding="0" cellspacing="0">
        <tr>
        <td bordercolor="#000000">
        <p align="center">
        <select name="metode" size="1">
        <option value="name" Selected="true">Name</option>
        <option value="year">Year</option>
        <option value="department">Department</option>
        </select> <input type="text" name="search" size="25"> &nbsp;<br>
        Search Alumni: <input type="submit" value="Go!!" name="Go"></p>
        </td>
        </tr>
        </table>
        </div>
        </form>
<HR color="blue">
</center>

<?php

  // Get the search variable from URL

  $var = @$_GET['search'] ;
  $trimmed = trim($var); //trim whitespace from the stored variable
// rows to return
$limit=20; 

// check for an empty string and display a message.
if ($trimmed == "")
  {
  //echo "<p>Please enter a search...</p>";
  $trimmed="%";
  }

// check for a search parameter
if (!isset($var))
  {
  //echo "<p>We dont seem to have a search parameter!</p>";
  //exit;
  }

// Build SQL Query  
if (!isset($_GET['metode'])||!isset($_GET['search'])){
$query ="SELECT * FROM alumni order by name";
// EDIT HERE and specify your table and field names for the SQL query
}
else{
$query ="SELECT * FROM alumni WHERE $metode LIKE \"%$trimmed%\"
  order by name"; // EDIT HERE and specify your table and field names for the SQL query
}
//echo "<br>$query<br>";
 $numresults=mysql_query($query);
 $numrows=mysql_num_rows($numresults);

// If we have no results, offer a google search as an alternative

if ($numrows == 0)
  {
  echo "<h4>Results</h4>";
  echo "<p>Sorry, your search: &quot;" . $trimmed . "&quot; returned zero results</p>";

// google
 echo "<p><a href=\"http://www.google.com/search?q=" 
  . $trimmed . "\" target=\"_blank\" title=\"Look up 
  " . $trimmed . " on Google\">Click here</a> to try the 
  search on google</p>";
  }
else{

// next determine if s has been passed to script, if not use 0
  if (empty($s)) {
  $s=0;
  }

// get results
  $query .= " limit $s,$limit";
  $result = mysql_query($query) or die("Couldn't execute query");

// display what the person searched for
echo "<p><b>You searched for: &quot;" . $var . "&quot;</b></p>";

// begin to show results set
echo "<B>Results</b><br>";
//$count = 1 + $s ;
?>
<center>
<table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000">
<tr>
<td width="50"><b>ID</b></td>
<td width="110"><b>Name</b></td>
<td width="200"><b>Email</b></td>
<td width="80"><b>Country</b></td>
<td width="200"><b>Address</b></td>
<td width="140"><b>Department</b></td>
<td width="50"><b>year</b></td>
</tr>
<?
// now you can display the results returned
  while ($row= mysql_fetch_array($result)) {
//show fields
  //echo "$count.)&nbsp;$title" ;
  //$count++ ;
  $variable1=$row["user_index"];
  $variable2=$row["name"]; 
  $variable3=$row["email"]; 
  $variable4=$row["country"];
  $variable5=$row["address"]; 
  $variable6=$row["department"]; 
  $variable7=$row["year"];

  //table layout for results 
  print ("<tr>");
  print ("<td><a href=\"modify.php?id=$variable1\">$variable1</a>&nbsp;<a href=\"results.php?action=delete&id=$variable1\"><b>D</b></a></td>"); 
  print ("<td>$variable2</td>"); 
  print ("<td><a href=\"mailto:$variable3\"><font color=\"#888577\">$variable3</font></a></td>"); 
  print ("<td>$variable4</td>"); 
  print ("<td>$variable5</td>"); 
  print ("<td>$variable6</td>"); 
  print ("<td>$variable7</td>");
  print ("</tr>"); 
  }
?>
</table>
</center>
<?
$currPage = (($s/$limit) + 1);

//break before paging
  echo "<br />";

  // next we need to do the links to other results
  if ($s>=1) { // bypass PREV link if s is 0
  $prevs=($s-$limit);
  print "&nbsp;<a href=\"$PHP_SELF?s=$prevs&q=$var\">&lt;&lt; 
  Prev 20</a>&nbsp&nbsp;";
  }

// calculate number of pages needing links
  $pages=intval($numrows/$limit);

// $pages now contains int of pages needed unless there is a remainder from division

  if ($numrows%$limit) {
  // has remainder so add one page
  $pages++;
  }

// check to see if last page
  if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {

  // not last page so give NEXT link
  $news=$s+$limit;

  echo "&nbsp;<a href=\"$PHP_SELF?s=$news&q=$var\">Next 20 &gt;&gt;</a>";
  }

$a = $s + ($limit) ;
  if ($a > $numrows) { $a = $numrows ; }
  $b = $s + 1 ;
  echo "<p>Showing results $b to $a of $numrows</p>";
}  
?>
<HR color="blue">
      <blockquote>
        <blockquote>
          <p align="center"><font color="#666699">Copyright
      2006, Bluegene Consulting Services<br></font>
      
          <a href="mailto:sudershanthaiba@gmail.com"><font color="#888577">Contact
          Webmaster</font></a>
        </blockquote>
      </blockquote>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -