Ok so I have this search page. That works fine. I get to the results page and I need to display the results of my multiple queries into a table. I also need it to loop to find all of the records from the database. This is what I have so far and it does not work.
<?php
$num = trim($_POST["num"]);
$user = trim ($_POST["user"]);
$start_date = trim ($_POST["start_date"]);
$end_date = trim ($_POST["end_date"]);
$campus = trim ($_POST["campus"]);
$building = trim ($_POST["building_alfred"]).trim ($_POST["building_wellsville"]);
$room = trim ($_POST["room"]);
$problem = trim ($_POST["problem"]);
$summary = trim ($_POST["summary"]);
$description = trim ($_POST["description"]);
$status = trim($_POST["status"]);
?>
<?php
$sql = "";
if(!empty($num)){
if (empty($sql)){
$sql = $sql."WHERE";
}else{
$sql = $sql."AND";
}
$sql = $sql." id LIKE '%$num%' ";
}
if(!empty($user)){
if (empty($sql)){
$sql = $sql."WHERE";
}else{
$sql = $sql."AND";
}
$sql = $sql." Requestor_Name LIKE '%$user%' ";
}
if(!empty($campus)){
if (empty($sql)){
$sql = $sql."WHERE";
}else{
$sql = $sql."AND";
}
$sql = $sql." Campus LIKE '%$campus%' ";
}
if(!empty($building_alfred)){
if (empty($sql)){
$sql = $sql."WHERE";
}else{
$sql = $sql."AND";
}
$sql = $sql." Building LIKE '%$building%' ";
}
if(!empty($building_wellsville)){
if (empty($sql)){
$sql = $sql."WHERE";
}else{
$sql = $sql."AND";
}
$sql = $sql." Building LIKE '%$building%' ";
}
if(!empty($room)){
if (empty($sql)){
$sql = $sql."WHERE";
}else{
$sql = $sql."AND";
}
$sql = $sql." Room LIKE '%$room%' ";
}
if(!empty($problem)){
if (empty($sql)){
$sql = $sql."WHERE";
}else{
$sql = $sql."AND";
}
$sql = $sql." Problem LIKE '%$problem%' ";
}
if(!empty($summary)){
if (empty($sql)){
$sql = $sql."WHERE";
}else{
$sql = $sql."AND";
}
$sql = $sql." Summary LIKE '%$summary%' ";
}
if(!empty($description)){
if (empty($sql)){
$sql = $sql."WHERE";
}else{
$sql = $sql."AND";
}
$sql = $sql." Description LIKE '%$description%' ";
}
if(!empty($status)){
if (empty($sql)){
$sql = $sql."WHERE";
}else{
$sql = $sql."AND";
}
$sql = $sql." Status LIKE '%$status%' ";
}
if(!empty($start_date)){
if (empty($sql)){
$sql = $sql."WHERE";
}else{
$sql = $sql."AND";
}
$sql = $sql." Date_Submitted >= '$start_date' ";
}
if(!empty($end_date)){
if (empty($sql)){
$sql = $sql."WHERE";
}else{
$sql = $sql."AND";
}
$sql = $sql." Date_Submitted <= '$end_date' ";
}
$sql = "SELECT * FROM workorder ".$sql.";";
?>
<?php
$link = mysql_connect("localhost", "uname", "pass");
mysql_select_db("helpdesk", $link);
$results = mysql_query($sql, $link);
$num_rows = mysql_num_rows($results);
echo "$num_rows Records Found\n";
mysql_free_result($results);
?>
<div id="content">
<div><br>
<table align="center" class="styled_results">
<tr>
<th class="clean">Edit</th>
<th>Work Order #</th>
<th>Requestor</th>
<th>Date</th>
<th>Location</th>
<th>Problem Type</th>
</tr>
</table>
<?php
$i = 1;
while($i <= $num_rows) {
echo '<table align = "center" class="styled_results">';
echo '<tr>';
echo '<td>'.$num.'</td>';
echo '<td>'.$user.'</td>';
echo '<td>'.$start_date.$end_date.'</td>';
echo '<td>'.$campus.'<br>'.$building.'<br>'.$room.'</td>';
echo '<td>'.$problem.'</td>';
echo'</tr>';
echo '</table>';
$i++;
}
?>
So where the echos are i am only displaying what the user entered into the search form. I need it to display all the information in the row that was found in the database. Anyone want to chang emy code and help a sista out!!!!!