Created
July 24, 2011 00:39
-
-
Save sgammon/1102048 to your computer and use it in GitHub Desktop.
Hampshire Connect help: search function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include("mainstyle.php"); | |
include("links.php"); | |
mysql_connect ("localhost", "db","password") or die (mysql_error()); | |
mysql_select_db ("db"); | |
$term = $_POST['term']; | |
//$sql = mysql_query("SELECT 'firstname','lastname' FROM users WHERE | |
MATCH('firstname','lastname') AGAINST('%$term%')"); | |
$sql = mysql_query("select * from users where firstname like '%$term%' or | |
lastname like '%$term%' or phone like '%$term%' or box like '%$term%' or interest1 | |
like '%$term%' or interest2 like '%$term%' or interest3 like '%$term%' or notes | |
like '%$term%'"); | |
?> | |
<html> | |
<head><title>Search Results</title> | |
<link rel="stylesheet" type="text/css" href="mainstyle.css" /> | |
</head> | |
<body> | |
<div class="contain"> | |
<table> | |
<tr> | |
<th>First Name</th><th>Last Name</th><th>Phone</th><th>Box</th><th>Academic | |
Interest</th><th>Academic Interest</th><th>Extracurricular Interest</th><th>Notes</ | |
th> | |
</tr> | |
<?php | |
while ($row = mysql_fetch_array($sql)){ | |
?> | |
<tr> | |
<td><?php echo $row['firstname']; ?></td><td><?php echo $row['lastname']; ?></ | |
td><td><?php echo $row['phone'];?></td><td><?php echo $row['box']; ?></td><td><? | |
php echo $row['interest1']; ?></td><td><?php echo $row['interest2']; ?></td><td><?php | |
echo $row['interest3']; ?></td><td><?php echo $row['notes']; ?></td> | |
</tr> | |
<?php | |
} | |
?> | |
</table> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment