sports-arena-website / view.php
view.php
Raw
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<?php
session_start();
// if don't have session user..then
if(!isset($_SESSION["staname"])){
    die("<script>alert('Please login first!');
    window.location.href='login.html';
    </script>");

    session_write_close();
}
?>

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Store Item List</title>
<link rel="shortcut icon" href="images/logo.png" type="image/x-icon" />
</head>
<style>
body{
    background-color:#303030;
}
table{
  background-color: #D2D2D2;
}
.button {
  background-color: #4CAF50; 
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  cursor: pointer;
}

.button2 {background-color: #008CBA;} 
.button3 {background-color: Red;} 

</style>
<body bgcolor="#FFEEEC">
<button class="button" onclick="window.location.href = 'staff_page.php';">Back</button>

<table border="1" style="text-align:center">
<tr>
<th>Item Name</th>
<th>Item Description</th>
<th>Item Category</th>
<th>Item Image</th>
<th>Item Stock</th>
<th>Item Price</th>

</tr>


<?php
include("conn.php");//add connection to the php page
$sql = "SELECT Item_Name, Item_Desc, Item_Category, Item_Image, Item_Stock, Item_Price FROM item";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
 echo ' 
      <tr>      
      <td> '.$row['Item_Name'].' </td>
      <td> '.$row['Item_Desc'].' </td>
      <td> '.$row['Item_Category'].' </td>
      <td><img src="'.$row['Item_Image']. '" width="75" height="75"/></td>
      <td> '.$row['Item_Stock'].' </td>
      <td> '.$row['Item_Price'].' </td>
      <td><a href="edit.php?id='.$row['Item_Name'].'"><button class="button button2">Edit</button></a></td>
      <td><a href="delete.php?id='.$row['Item_Name'].'"><button class="button button3">Delete</button></a></td>                              
  		</tr>';     
}

} else { echo "0 results"; }
?>

</table>
</body>

</html>