Design a website for ranking three products, i.e., Product1, Product2 and Produc
ID: 3838556 • Letter: D
Question
Design a website for ranking three products, i.e., Product1, Product2 and Product3 using PHP, MySQL and Apache. The running environment is the same as the Lab 2. You need to design a database and a table to support this website. The following figure is the initial webpage without any ranking input:
When the user clicks the “Ranking Products” hyperlink, the following product ranking webpage will appear:
All the four form inputs should not be empty, otherwise, warnings will be displayed with a “Go Back” hyperlink for guiding users to go back to the ranking page (here is the case that all the four inputs are empty):
In addition, all the rank input numbers should be between 1 and 5. For any rank input numbers that are out of this range, warnings will show (the following example, the rank numbers for Product1 and Product3 are out of range). The “Go Back” hyperlink will show guiding users to go back to the ranking page:
When multiple user rank input numbers have been submitted:
You need to turn in all your codes (including all your SQL statements for database creation, sql script file, and all your Website codes, php and html) in a zipped file. Test your codes by sample runs. Turn in appropriate Web browser display (the similar webpage as the last snapshot of the demo, however, the user names should be different from the ones displayed in the demo webpage) to show that your sample runs are successful.
Hint:You need SQL SUM function.
Homepage local host/cita215/assignments/a6/ Product Ranking Results Ranking Products Producti Product2 Product Customer Name Total GradeExplanation / Answer
SELECT *
FROM table
WHERE
(
product
(
SELECT TOP (3) product
FROM table as table1
GROUP BY productid
ORDER BY product DESC
)
)
<div class="products">
<?php
$current_url = urlencode($url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$results = $mysqli->query("SELECT PRODUCTS");
if($results){
$products_item = '<ul class="products">';
while($obj = $results->fetch_object())
{
$products_item .= <<<EOT
<li class="product">
<form method="post" action=".php">
<div class="product-content"><h3>{$obj->product_name}</h3>
<div class="product-desc">{$obj->product_desc}</div>
<div class="product-">
Price {$currency}{$obj->price}
<fieldset>
</fieldset>
<input type="hidden" name="product_code" value="{$obj->product_code}" />
<input type="hidden" name="return_url" value="{$current_url}" />
<div align="center"><button type="submit" class="add_to_cart"></button></div>
</div></div>
</form>
</li>
}
$products_item .= '</ul>';
echo $products_item;
}
?>
</div>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.