Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nicolai code #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
<?php include 'config.php'; ?>
<?php include 'searchBarHeader.php'; ?>
<?php include 'searchBarHeader.php';?>
<?php
$query = "SELECT * FROM messages ORDER BY id DESC";
$messages = mysqli_query($connection, $query);
?>
<!doctype html>
<html>





<!--<!doctype html>-->
<!--<html>-->







Expand All @@ -19,7 +28,7 @@
</div>

<div class="gallery">
<ahref="dynamicProductList.php?category=Home and Garden">
<a href="dynamicProductList.php?category=Home and Garden">
<img src="Images/pic_homeGarden.jpg" alt="Home and Garden" width="300" height="200">
</a>
<div class="desc">Home & Garden</div>
Expand Down
File renamed without changes.
147 changes: 147 additions & 0 deletions Buyer/Browse/dynamicProductList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<?php include 'config.php'; ?>
<?php include 'searchBarHeader.php'; ?>
<script type="text/javascript"
src="dynamicProductListController.js">
</script>


<?php

$productSearch = $_POST["search"];

$category2 = $_POST["searchCategories"];

$category1 = $_GET["category"];

$dateNow = date("Y-m-d H:i:s");

echo $productSearch;
echo $category2;
echo $category1;
?>

<div id="container">

<select name="Name Alphabetical" id="nameAlphabetical" onclick="sortName()">
<option value="" disabled selected>Name</option>
<option value="Name Alphabetical">Name Alphabetical</option>
</select>

<select name="Ending soon" id="endingSoon" onclick="endingSoon(value)">
<option value="" disabled selected>Sort by End Date</option>
<option value="End soon first">End soon first</option>
<option value="End soon last">End soon last</option>
</select>

<select name="Condition Filter" id="condition" onclick="filterCategory()">
<option value="" disabled selected>Condition</option>
<option value="e">New or Used</option>
<option value="New">New</option>
<option value="Used">Used</option>
</select>

<select name="Reserve price" id="reservePrice" onclick="sortReservePrice(value)">
<option value="" disabled selected>Sort Reserve Price</option>
<option value="High to Low">High to Low</option>
<option value="Low to High">Low to High</option>
</select>

<select name="Highest bid" id="highestBid" onclick="sortHighestBid(value)">
<option value="" disabled selected>Sort Highest Bid</option>
<option value="High to Low">High to Low</option>
<option value="Low to High">Low to High</option>
</select>



</div>


<div id="container2">









<?php
if(isset($category1)) {

$sql = "SELECT prod_name, prod_category, prod_description, prod_start_price, prod_reserve_price, prod_end_date, prod_condition, prod_picture, prod_highest_price FROM product WHERE prod_category = '$category1' AND '$dateNow' <= prod_end_date";
echo "first loop";
}


// run search for all categories
else if ($category2 == "*") {
$sql = "SELECT prod_name, prod_category, prod_description, prod_start_price, prod_reserve_price, prod_end_date, prod_condition, prod_picture, prod_highest_price FROM product WHERE prod_name LIKE '%$productSearch%' AND '$dateNow' <= prod_end_date";
echo "second loop";
}

// run search within a category
else {

$sql = "SELECT prod_name, prod_category, prod_description, prod_start_price, prod_reserve_price, prod_end_date, prod_condition, prod_picture, prod_highest_price FROM product WHERE (prod_name LIKE '%$productSearch%') AND (prod_category = '$category2') AND '$dateNow' <= prod_end_date";
echo "third loop";
}





$result = mysqli_query($db, $sql);


if (mysqli_num_rows($result) > 0) {
// output data of each row
?>
<table id="myTable">
<tr>
<th></th>
<th>Name</th>
<th>Category</th>
<th>End date</th>
<th>Condition</th>
<th>Reserve Price</th>
<th>Current Bid</th>
</tr>

<?php
while($row = mysqli_fetch_assoc($result)) { ?>
<tr>
<td> <?php $picture1 = $row["prod_picture"];
// below needs changing when put on server
$picture2 = "Images/" . $picture1;
?>
<img src= "<?php echo $picture2?>" alt="Image picture" width="300" height="200"> </td>
<td><?php echo $row["prod_name"]; ?> </td>
<td><?php echo $row["prod_category"]; ?> </td>
<td><?php echo $row["prod_end_date"]; ?> </td>
<td><?php echo $row["prod_condition"]; ?> </td>
<td><?php echo $row["prod_reserve_price"]; ?> </td>
<td><?php echo $row["prod_highest_price"]; ?> </td>





</tr>
<br>
<?php }
?>

<?php
} else {
echo "0 results";
}

mysqli_close($db);
?>

</div>



Loading