HI all,
I am pretty new to php and am trying to teach myself - i dont have any massive project in mind and have just been playing around. I decided to make a POS like system.
I was quite proud of my self, i created some php that got information from the db and displayed a box per record returned.
The database is returning products that a bar might sell, beer, wine, spirits and each product regardless of catagory is being put in a box on the screen.
I wanted to have a button that when pressed only shows the items in the database with the product_catagory of wine - same with spirits and softdrinks.
I have added my buttons that i want to do the work but at this point i am stuck.
After doing quite a lot of reading it seems that i am going to need to use "AJAX" - is this the case?
Below is just a test page that has the button on that i will use to call the function
<!DOCTYPE html>
<html>
<head>
<title>page</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="java.js"></script>
</head>
<body>
<?php include "dbconn.php" ?>
<?php include "testing.php" ?>
<div id="spiritButton" style="width:100px;height:100px;background:red">Click Me</div>
</body>
</html>
Below is the fucntion that pulls back all of the products, i wanted to change the sql command depending on which button is pressed (as in only show spirits when you click "spirits" but change with other product catagorys)
<?php
$sql = "SELECT * FROM products";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$pro_id = productButton.$row["product_id"];
$pro_display = $row["product_name"]. "<br/><br/>"."£". $row["product_price"];
echo <<< "EOT"
<div class="productButton" id="$pro_id">$pro_display</div>
EOT
;
}
} else {
echo "No results found";
}
$conn->close();
?>
I would really appreciate any help on this but please be as gentle as possible as my ability is likely much lesser than yours.
Kind Regards
Adam