I am sorry sir. I thank you for all your help so far, but I am officially lost now. I tried moving around the while loop with the fetch array and it still would not work right but I believe I probably did it wrong. Oh, and the 'Category' is a dropdown down menu and the criteria is the value to search the category with:
Code:
<form method="post" action="index.php">
<input type="hidden" name="submitted" value="true" />
<label>Search Category:
<select name="category">
<option value="StreetName">Street Name</option>
</select>
</label>
<label>Search Criteria: <input type="text" name="criteria" /></label>
<input type="submit" name="search" value="Search"/>
</form>
This is my code, thusfar:
PHP Code:
<center><h1><u> MSAG Database </u></h1>
<br>
<br>
<?php include 'includes/menu.php'; ?>
<form method="post" action="index.php">
<input type="hidden" name="submitted" value="true" />
<label>Search Category:
<select name="category">
<option value="StreetName">Street Name</option>
</select>
</label>
<label>Search Criteria: <input type="text" name="criteria" /></label>
<input type="submit" name="search" value="Search"/>
</form>
</center>
<?php
include 'includes/db/connect.php';
if(isset($_POST['search']))
{
$category = $_POST['category'];
$criteria = $_POST['criteria'];
$query = "SELECT * FROM MSAG WHERE $category LIKE '%$criteria%' ORDER BY StreetName ASC";
$resource=sqlsrv_query($conn, $query) or die(print_r(sqlsrv_errors(), true));
}
?>
<form action="" method="post">
<table align="center" border="1" cellpadding="2" cellspacing="2" width="100%" >
<tr align = 'center'>
<td><b>Street Name</b></td>
<td><b>Details</b></td>
</tr>
<?php
while($result=sqlsrv_fetch_array($resource))
{
echo "
<tr align = center>
<td>".$result['StreetName']."</td>
<td><a href=\"modify2.php?id=".$result['StreetID']."\"><input type=\"button\" name = \"details\" value = \"Details\" /></a></td>
</tr>
";
}
?>
</table>
</form>