* Sunda Cyber Army 2k17 *
Indonesia Defacer ~
<?php
if(empty($_REQUEST['device_name']) &&
$_REQUEST['manufacturer_id'] == "" &&
$_REQUEST['system_id'] == "" &&
$_REQUEST['type_id'] == "") {
echo "Please go through search page. (or redirect)";
header('Location: search.php');
exit();
}
$host = "webdev.iyaserver.com";
$userid = "dent_test";
$userpw = "Acad276_Ttrojan_Dev2Ex@m";
$db = "dent_exam";
$mysql = new mysqli(
$host,
$userid,
$userpw,
$db
);
if($mysql->connect_errno) {
echo "db connection error : " . $mysql->connect_error;
exit();
}
?>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Acad276 Practical Exam: Results</title>
<style>
.container {
width: 600px;
margin: auto;
}
h1 {
margin: auto;
text-align: center;
background-color: #900;
color: #FC0;
height: 60px;
line-height: 60px;
}
.num-results {
margin: 20px 10px;
}
table {
margin: auto;
margin-bottom: 20px;
width: 80%;
border-collapse: collapse;
}
th, td {
border: 1px solid #900;
border-collapse: collapse;
padding: 10px;
text-align: center;
}
img {
width: 100px;
}
.nav-link{
margin: 10px 0px;
font-size: 14px;
}
</style>
</head>
<body>
<div class="container">
<h1>Mobile Device Database: Search Results</h1>
<div class="nav-link">
<a href="search.php"><< Back to Search Page</a>
</div>
<?php
$sql = "
SELECT device.device_id, device.name AS name, device.price,
make.manufacturer AS manufacturer_name,
os.system AS system_name,
devicetype.type AS type_name,
device.img_url
FROM device, make, os, devicetype
WHERE device.manufacturer_id = make.manufacturer_id
AND device.system_id = os.system_id
AND device.type_id = devicetype.type_id
";
if (!empty($_REQUEST['name'])) {
$sql .= " AND device.name LIKE '%" . $_REQUEST['name'] . "%'";
}
if ($_REQUEST['manufacturer_id'] != "all") {
$sql .= " AND device.manufacturer_id = '" . $_REQUEST["manufacturer_id"] . "'";
}
if ($_REQUEST['system_id'] != "all") {
$sql .= " AND device.system_id = '" . $_REQUEST["system_id"] . "'";
}
if ($_REQUEST['type_id'] != "all") {
$sql .= " AND device.type_id = '" . $_REQUEST["type_id"] . "'";
}
$results = $mysql->query($sql);
?>
<div class="num-results">
Your search returned
<?php echo $results->num_rows; ?>
results.
</div>
<table>
<tr>
<th>Name</th>
<th>Price</th>
<th>Manufacturer</th>
<th>System</th>
<th>Type</th>
</tr>
<?php
while($currentrow = $results->fetch_assoc()){
echo "<tr>";
echo "<td><a href='details.php?id=" . $currentrow["device_id"] . "'>" . $currentrow["name"] . "</a></td>";
echo "<td>" . $currentrow["price"] . "</td>";
echo "<td>" . $currentrow["manufacturer_name"] . "</td>";
echo "<td>" . $currentrow["system_name"] . "</td>";
echo "<td>" . $currentrow["type_name"] . "</td>";
echo "</tr>";
}
?>
<!--
****** SAMPLE OUTPUT ROW ******
-->
<!-- <tr>-->
<!---->
<!-- <td><a href="details.php?id=10">Pixel</a></td>-->
<!---->
<!-- <td>549.00</td>-->
<!---->
<!-- <td>Google</td>-->
<!---->
<!-- <td>Android</td>-->
<!---->
<!-- <td>Smartphone</td>-->
<!---->
<!-- </tr>-->
<!---->
<!-- <tr>-->
<!---->
<!-- <td><a href="details.php?id=11">Pixel 2</a></td>-->
<!---->
<!-- <td>649.00</td>-->
<!---->
<!-- <td>Google</td>-->
<!---->
<!-- <td>Android</td>-->
<!---->
<!-- <td>Smartphone</td>-->
<!---->
<!-- </tr>-->
<!---->
<!-- <tr>-->
<!---->
<!-- <td><a href="details.php?id=12">Pixelbook</a></td>-->
<!---->
<!-- <td>999.00</td>-->
<!---->
<!-- <td>Google</td>-->
<!---->
<!-- <td>Android</td>-->
<!---->
<!-- <td>Laptop</td>-->
<!---->
<!-- </tr>-->
</table>
</div>
</body>
</html>