Ok I have a page that I read and write to my table/columns for server information of systems.
I want to do an if statement for OS. If os = windows do> list windows servers info. Basically I want to filter out the other operating systems within the column 'os' but still display all the tables information for the windows servers.
code:
<?php
session_start();
//connect to database
$mysqli = mysqli_connect("localhost", "user", "password", "inventory");
$display_block = "<h1>Server List</h1>";
//check for cart items based on user session id
$get_cart_sql = "SELECT id, hostname, asset, ip, os, backup, dhcp, model, stag, purchased, supexp, patched FROM hostname ORDER BY hostname";
$get_cart_res = mysqli_query($mysqli, $get_cart_sql) or die(mysqli_error($mysqli));
if (mysqli_num_rows($get_cart_res) < 1) {
//print message
$display_block .= "<p>You have no items in your cart.
Please <a href=\"seestore.php\">continue to shop</a>!</p>";
} else {
//get info and build cart display
$display_block .= "
<table celpadding=\"3\" cellspacing=\"2\" border=\"1\" width=\"98%\">
<tr>
<th>Hostname</th>
<th>Operating System</th>
<th>Service Tag/SN</th>
<th>Purchase Date</th>
<th>Support Exp. Date</th>
<th>Asset Tag</th>
<th>IP</th>
<th>DHCP</th>
<th>Server Model</th>
<th>Patched</th>
<th>Backup Policy</th>
<th>Edit</th>
<th>Delete</th>
</tr>";
while ($cart_info = mysqli_fetch_array($get_cart_res)) {
$id = $cart_info['id'];
$hostname = stripslashes($cart_info['hostname']);
$os = $cart_info['os'];
$stag = $cart_info['stag'];
$purchased = $cart_info['purchased'];
$supexp = $cart_info['supexp'];
$asset = $cart_info['asset'];
$ip = $cart_info['ip'];
$dhcp = $cart_info['dhcp'];
$model = $cart_info['model'];
$patched = $cart_info['patched'];
$backup = $cart_info['backup'];
$display_block .= "
<tr>
<td align=\"center\">$hostname <br></td>
<td align=\"center\">$os <br></td>
<td align=\"center\">$stag <br></td>
<td align=\"center\">$purchased <br></td>
<td align=\"center\">$supexp <br></td>
<td align=\"center\">$asset <br></td>
<td align=\"center\">$ip <br></td>
<td align=\"center\">$dhcp <br></td>
<td align=\"center\">$model <br></td>
<td align=\"center\">$patched <br></td>
<td align=\"center\">$backup <br></td>
<td align=\"center\"><a href='edit.php?cmd=edit&id=$id'>edit</a></td>
<td align=\"center\"><a href=\"remove.php?id=".$id."\">remove</a></td>
</tr>";
}
$display_block .= "</table>";
}
?>
<html>
<head>
<title>Server List</title>
</head>
<body>
<?php echo $display_block; ?>
</body>
</html>