* Sunda Cyber Army 2k17 *
Indonesia Defacer ~
<?php
// The following code will create a connection to a specific database (dent_dvd, etc.)
// STEP 1: Create a connection to the database
$host = "webdev.iyaserver.com";
$userid = "<youruserid>";
$userpw = "<yourpw>";
$db = "<database name>";
// You need to edit the userid, userpw and db above to your account values
include "../pdloginvariables.php"; // you can delete this line
$mysql = new mysqli(
$host,
$userid,
$userpw,
$db
);
// checks to see if there were any issues creating the db connection
if($mysql->connect_errno) {
echo "db connection error : " . $mysql->connect_error;
exit();
}
else { // you can choose to delete the else clause
echo "<br>db connection success!<br>";
}
// Typically we would then create a SQL statement to submit to the db:
// STEP 2: Create a sql statement and submit to database, save returned results
$sql = "SELECT * FROM movieView WHERE genre = 'Comedy' ORDER BY title";
// Then we submit the query to the db connection (created above) and check for problems
$results = $mysql->query($sql);
if(!$results) {
echo "SQL error: ". $mysql->error . " running query <hr>" . $sql . "<hr>";
exit();
}
else { // you can choose to delete the else clause
echo "<br>all good... here come the results...<br>";
}
// STEP 3: Display the resulting data, and possibly meta data like number of returned records
echo "<br>I found <strong>" . $results->num_rows . "</strong> records.<br><br>";
while($currentrow = $results->fetch_assoc()) {
echo "Title: " . $currentrow["title"] . "<br>";
}
/*
note the actual column/field names from your query (like title above)
are based on the fields you listed in your SELECT clause
*/
$mysql -> close();
/*
best practice is to "close up" the active connection to the database when done
you want to do this at the END of your file
*/
?>