Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'ConnectPicture.php';
- $showtables = "SELECT COUNT(*) FROM picturetable";
- $tableexists = mysqli_query($connectedToDatabasePicture, $showtables);
- $hello = 1;
- if(!$tableexists){
- displaynoPictureText();
- }else{
- displayPicture();
- }
- function displayPicture(){
- global $connectedToDatabasePicture;
- $getpicture = "SELECT * FROM picturetable ORDER BY cid DESC";
- $result = mysqli_query($connectedToDatabasePicture, $getpicture);
- // While a row of data exists, put that row in $row as an associative array
- echo $result;
- while($row = mysqli_fetch_assoc($result)){
- $filepath = $row['path'].$row['picturename'];
- echo "<img src=$filepath style="width:100%">";
- echo $row['textarea'];
- }
- }
- function displaynoPictureText(){
- echo"NO PICTURE TO DISPLAY";
- }
- ?>
- <?php
- //Servername
- $mysql_servername = 'localhost';
- //Username for the database
- $mysql_user = 'root';
- //Password for the database
- $mysql_password = '7JwHEHVS4haREdWB';
- //Needs to run a connection to a database. The information about which database to connect to should be inserted into the paranthesis.
- //Servername, username for the database, and the password for the database.
- $connectedToDatabaseComments = mysqli_connect($mysql_servername,$mysql_user,$mysql_password);
- //If there is no connection, go inside the first if
- if (!$connectedToDatabaseComments)
- {
- //Die function, which kills the connection
- die("Database connection failed: " . mysqli_connect_error());
- }else
- {
- //Else go inside here
- //Select the database in the second parameter from connection in the first parameter
- //It returns true or false based on if the database could be selected
- $databaseSelectedComments = mysqli_select_db($connectedToDatabaseComments,"blogdatabase");
- //If the database can not be selected go to the if
- if(!$databaseSelectedComments)
- {
- //Print database connection failed
- echo "Database connection failed";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement