diff --git a/add_offer.php b/add_offer.php
new file mode 100644
index 0000000..60ae9d4
--- /dev/null
+++ b/add_offer.php
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+ Board
+
+
+
+
+
+
+
+
+
+
+
Enter your offer
+
+
+
+
+
diff --git a/functions.php b/functions.php
index aaf7507..73860e0 100644
--- a/functions.php
+++ b/functions.php
@@ -209,7 +209,11 @@ function show_demand ()
echo "
Description:";
- echo $demand_rows->demandText;
+ echo "$demand_rows->demandText
";
+ echo "
";
}
function post_offer()
@@ -217,15 +221,53 @@ function post_offer()
if (isset($_POST['submit'])) {
global $con;
$userId = get_userid();
+ $demandId = $_POST['demandId'];
$pieces = $_POST['pieces'];
$price = $_POST['price'];
$qualityId = $_POST['quality'];
$text = $_POST['text'];
// Inserts Data into Database
- $sql = "INSERT INTO offers (pieces, text, price, userId, qualityId)
- VALUES ('$pieces', '$text', '$price', '$userId', '$qualityId')";
+ $sql = "INSERT INTO offers (pieces, text, price, userId, qualityId,
+ demandId)
+ VALUES ('$pieces', '$text', '$price', '$userId', '$qualityId',
+ '$demandId')";
$result = mysqli_query($con, $sql) or die(mysqli_error($con));
}
}
+function show_offer ()
+{
+ global $con;
+ $demandId = $_POST['demandId'];
+
+ // get the offers matching the demand from the database
+ $offer_query = "SELECT * FROM offers where demandId='$demandId'";
+ $offer_query_result = mysqli_query($con, $offer_query) or
+ die(mysqli_error($con));
+
+ // if the query on the database returned data print the data
+ while ($offer_rows = $offer_query_result->fetch_object()) {
+ $qualityId = $offer_rows->qualityId;
+ $quality_query = "SELECT * FROM quality where qualityId='$qualityId'";
+ $quality_query_result = mysqli_query($con, $quality_query) or
+ die(mysqli_error($con));
+ $quality_rows = $quality_query_result->fetch_object();
+
+ echo "
Offer Nr: " . $offer_rows->offerId;
+ echo "
+
";
+ echo "
Amount available: " . $offer_rows->pieces;
+ echo "
+
";
+ echo "
Price per piece: " . $offer_rows->price;
+ echo "
+
";
+ echo "
Provided Quality: " . $quality_rows->qualityName;
+ echo "
+
+
Description:";
+ echo $offer_rows->text . "
+
";
+ }
+}
?>
diff --git a/show_demand.php b/show_demand.php
index 97dc1d6..c13f7c7 100644
--- a/show_demand.php
+++ b/show_demand.php
@@ -31,9 +31,8 @@ include 'functions.php';
show_demand();
?>
-