Sunda Cyber Army


* Sunda Cyber Army 2k17 *
Indonesia Defacer ~


Path : /home/dent/public_html/acad274/
File Upload :
Current File : /home/dent/public_html/acad274/php_sample_code.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 title LIKE '%dog%'";

// 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)
*/


// close php block
?>
<html>
<head>
        <title>Dog movies</title>
    <style>
        table { width: 900px; background-color: steelblue;}
        td { width: 200px; background-color: lightsteelblue; }
        .header { color:white; background-color: steelblue;}
    </style>
</head>
<body>
<h3>"Dog" movies</h3>

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

<table cellpadding="9" cellspacing="9">
<tr>
    <td class="header">Title<hr></td>
    <td class="header">Rating<hr></td>
    <td class="header">Genre<hr></td>
    <td class="header">Studio<hr></td>
</tr>

<?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
    ?>
<tr>
    <td><strong><?= $currentrow["title"] ?></strong></td>
    <td>Rated <?= $currentrow["rating"] ?></td>
    <td><em><?= $currentrow["genre"] ?></em></td>
    <td><?= $currentrow["label"] ?></td>
</tr>
    <!-- end of looped code -->
    <?php
} // end php loop
// back to html for further text, html page content
?>
</table>

</body>
</html>