* Sunda Cyber Army 2k17 *
Indonesia Defacer ~
<?php
// create connection to database
$host = "webdev.iyaserver.com";
$userid = "dent_student";
$userpw = "code4Studentuse";
$db = "dent_movies";
$mysql = new mysqli(
$host,
$userid,
$userpw,
$db);
if($mysql->connect_errno) {
echo "db connection error : " . $mysql->connect_error;
exit();
}
// base query
$sql = "SELECT * from view1 WHERE 1=1";
// ADD ON FILTER
$sql .= " AND title like 'R%' AND rating = 'PG-13' ";
// ADD ON sort order
$sql .= " ORDER BY title";
// submit query to database, store returned data as $results
$results = $mysql->query($sql);
if(!$results) {
echo "SQL error: ". $mysql->error . " running query <hr>" . $sql . "<hr>";
exit();
} else {
// put sql into comment block of webpage
echo "<!-- SQL: $sql -->";
}
/*
Note: $results is a database "result set".
It has a property $results->num_rows that is a number (how many rows of data)
*/
// Code to output one sample row with list of columns
$sample = $results->fetch_assoc();
echo "<!-- Sample first row of data <br>";
print_r($sample);
echo "</pre> -->";
$results->data_seek(0); // reset results
// close php block
?>
<h3>PG-13 movies that start with "R" results</h3>
Returning <?= $results->num_rows ?> Movies
<hr>
<style>
/* small stylesheet to set up movie formatting styles */
</style>
<?php // BACK into php
// create output loop around rows of database results
while( $currentrow = $results->fetch_assoc() ) { // OPEN/active php loop
// while in repeating loop, back into html mode
?>
<!-- Text, html and php output code below will repeat over and -->
Movie <?= $currentrow["title"] ?>,
Rated <?= $currentrow["rating"] ?>
<br>
<!-- end of looped code -->
<?php
} // end php loop
// back to html for further text, html page content
?>