* Sunda Cyber Army 2k17 *
Indonesia Defacer ~
<!DOCTYPE html>
<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>
<?php
$host = "webdev.iyaserver.com";
$userid = "dent_test";
$pwd = "Acad276_Ttrojan_Dev2Ex@m";
$db = "dent_exam";
$mysql = new mysqli($host, $userid, $pwd, $db);
if($mysql->connect_errno) {
echo "db connection error : " . $mysql->connect_error;
exit();
}
?>
<div class="container">
<h1>Mobile Device Database: Search Results</h1>
<?php
// I have absolutley no idea why this is wrong. I want to select every column from make,os,devicetype (and i think device??)
// where the following connections are true. It doesn't make sense why this doesnt work.
//If it did then the rest of the page would know what I'm trying to call when I ask for results from the user's selected values.
$sql = "SELECT * FROM make,os,devicetype,device WHERE 1=1
AND make.manufacturer_id = device.manufacturer_id
AND os.system_id = device.system_id
AND devicetype.type_id = device.type_id";
echo $sql;
// REQUIRED: Stop the page and display an error message if any of the drop-down values are missing.
$results = $mysql -> query($sql);
if(!$results) {
echo "<hr> ERROR!" . $mysql -> error;
echo "<hr>SQL: " . $sql;
}
// this is also causing some errors. In theory, this section should show all results if the user leaves the select as "all"
// I know manufacturer_id can be ambigous, but I was using the name from the search page and am not sure why this is casuing an error.
if($_REQUEST['manufacturer_id'] != "ALL") {
$sql .= " AND manufacturer_id = '" . $_REQUEST["manufacturer_id"] . "'";
}
if($_REQUEST['system_id'] != "ALL") {
$sql .= " AND system_id = '" . $_REQUEST["system_id"] . "'";
}
if($_REQUEST['type_id'] != "ALL") {
$sql .= " AND type_id = '" . $_REQUEST["type_id"] . "'";
}
echo "<br>Results: " . $results ->num_rows . "<br>";
//I know this whole section is likley pretty wrong.... in theory, im calling the current row and all of the corisponding data
// however, the error in the select statement above makes it so i can't test this.
// I think becasue I haven't used a table in a long time, the syntax confused me. Not sure what
while ($current = $results->fetch_assoc()) {
"<table> <tr> <th> <a href='details.php'> Name:".
$current ["device.name"]."</a>".
"</th> <th>Price:".
$current ["device.price"].
"</th> <th>Manufacturer:".
$current ["make.manufacturer"].
"</th> <th>System:".
$current ["system"].
"</th> <th>Type:".
$current ["type"].
"</th> </tr> Edit" ."<br> <br>";
}
?>
<div class="nav-link">
<a href="search.php"><< Back to Search Page</a>
<!-- add php here about redirecting if missing data. IDK what that would be though. -->
</div>
<div class="num-results">
Your search returned
<strong>3</strong>
results.
</div>
<table>
<tr>
<th>Name</th>
<th>Price</th>
<th>Manufacturer</th>
<th>System</th>
<th>Type</th>
</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>