Skip to content

Commit

Permalink
Added Simple Database Connection
Browse files Browse the repository at this point in the history
  • Loading branch information
MFox committed Mar 25, 2017
1 parent 3a28b54 commit 2c3600e
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 0 deletions.
15 changes: 15 additions & 0 deletions html-ONLY-site/priv_includes/config.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
define('OFFLINE_FLG', FALSE);
define('OFFLINE_MSG','Site is currently down for maintenance.');

define('AUTHENTICATION_FLG', TRUE);

// BASE URL
define('BASE_URL', 'http://wellreportapp.uconn.edu/');

// Site Name
define('SITE_NAME','WELLO');

//database connection info file & database related php functions, any page can reference this via absolute URL
define('MYSQL_CONN_FILE', 'mysqli_oo_connect.php');
?>
20 changes: 20 additions & 0 deletions html-ONLY-site/priv_includes/mysqli_oo_connect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
// Declare and set constants for DB connection parameters
DEFINE ('DB_USER', 'db10e41481317066');
DEFINE ('DB_PASSWORD','jXLUjNG/cQxm4VJ1SionhDKdcT4BT1Dos7sZMddIapa/8LYDpDNz+3hwGCz8Shon');
DEFINE ('DB_HOST','localhost');
DEFINE ('DB_NAME','db10e41481317066');

//Making a Connection
$mysqli = new MySQLi(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

//Verify the Connection
if ($mysqli->connect_error) { //if there is a connection error
echo $mysqli->connect_error; //echo error to screen
unset($mysqli); //delete the object created on line 19
}
else { //establish encoding
$mysqli->set_charset('utf8');
}

/* terminating php tag "?>" not needed if this file end in .php extension */
123 changes: 123 additions & 0 deletions html-ONLY-site/wells-list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php
$mysqli = new mysqli("localhost", "db10e41481317066", "jXLUjNG/cQxm4VJ1SionhDKdcT4BT1Dos7sZMddIapa/8LYDpDNz+3hwGCz8Shon", "db10e41481317066");

/* check connection */
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}

$query = "SELECT Well_Street_Name FROM well_completion_report";

?>

<!doctype html>
<html class="no-js" lang="">

<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<!-- Place favicon.ico in the root directory -->
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/well-card.css">

<script src="js/vendor/modernizr-2.8.3.min.js"></script>
</head>






<body>
<!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<!-- Add your site or application content here -->






<nav class="top-nav">
<button onclick="document.getElementById('menu').classList.toggle('closed'); document.getElementById('close-menu').classList.toggle('closed')"><img src="img/menu.svg" alt="menu" /></button><h1>Nearby Wells</h1>
<button><a href="search.html"><img src="img/search.svg" alt="menu" /></a></button>

<div class="close-menu closed" id="close-menu" onclick="document.getElementById('menu').classList.toggle('closed'); document.getElementById('close-menu').classList.toggle('closed')"></div>
<div class="slide-menu closed" id="menu">
<p>Currntly signed in as:
<h3>my.name@ct.gov</h3>
</p>
<a href="#">Logout</a>
<a class="settings" href="#">Settings</a>

</div>
</nav>

<main>
<?php
if ($result = $mysqli->query($query)) {

/* fetch associative array */
while ($row = $result->fetch_assoc()) {
echo'
<a href="details.html">
<div class="well-card clearfix">
<div class="well-img"></div>
<div>
<h2>'.$row["Well_Street_Name"].'</h2>
<p>short well description</p>
</div>
</div>
/a>';
//printf ($row["Well_Street_Name"]);
}

/* free result set */
$result->free();
}
?>
</main>

<nav class="bottom-nav">
<button><a href="map.html"><img src="img/map.svg" alt="menu" /></a></button>
<button><a href="wells-list.html"><img src="img/well.png" alt="menu" /></a></button>
</nav>







<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script>
window.jQuery || document.write('<script src="js/vendor/jquery-1.12.0.min.js"><\/script>')
</script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script>
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
<script>
(function (b, o, i, l, e, r) {
b.GoogleAnalyticsObject = l;
b[l] || (b[l] = function () {
(b[l].q = b[l].q || []).push(arguments)
});
b[l].l = +new Date;
e = o.createElement(i);
r = o.getElementsByTagName(i)[0];
e.src = 'https://www.google-analytics.com/analytics.js';
r.parentNode.insertBefore(e, r)
}(window, document, 'script', 'ga'));
ga('create', 'UA-XXXXX-X', 'auto');
ga('send', 'pageview');
</script>
</body>

</html>

0 comments on commit 2c3600e

Please sign in to comment.