Sunda Cyber Army


* Sunda Cyber Army 2k17 *
Indonesia Defacer ~


Path : /home/dent/public_html/acad274/
File Upload :
Current File : /home/dent/public_html/acad274/movies.php

<?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 genre = 'Horror' OR rating = 'R' AND (genre='Sci-Fi' OR genre LIKE 'Action%') ";

// 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 -->\n";
}

/*
    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 "\n<!-- Sample first row of data \n";
print_r($sample);
echo "</pre> \n -->";
$results->data_seek(0); // reset results

// close php block
?>

<h3>Results</h3>

Returning <?= $results->num_rows ?> Movies
<hr>

<?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 -->
<strong><?= $currentrow["title"] ?></strong>,
    Rated <?= $currentrow["rating"] ?>
    (<em><?= $currentrow["genre"] ?></em>)
<br>

    <!-- end of looped code -->
<?php
    } // end php loop
// back to html for further text, html page content
?>