created basic DB structure and accessing db

This commit is contained in:
Joshua Ashton
2025-03-05 18:55:04 -07:00
parent 8d244e586d
commit 54228c4e8e
16 changed files with 151 additions and 16 deletions
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
+14
View File
@@ -0,0 +1,14 @@
<?php
$nav = '
<nav>
<ul>
<li><a href="home.php">Home</a></li>
<li><a href="account.php">Account</a></li>
<li><a href="admin.php">Admin</a></li>
<li><a href="articles.php">Articles</a></li>
</ul>
</nav>
';
echo $nav;
Regular → Executable
+4
View File
@@ -0,0 +1,4 @@
<?php
include_once ('includes/sql.php');
function login($username, $password_hash) {}
Regular → Executable
+11 -10
View File
@@ -5,11 +5,11 @@ $dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..');
$dotenv->safeLoad();
// Use environment variables for the database password and IP address.
// $db_user = $_ENV['DATABASE_USER'];
$db_user = $_ENV['DATABASE_USER'];
$db_pass = $_ENV['DATABASE_PASSWORD'];
define('HOST', 'localhost');
define('USER', 'root');
define('USER', $db_user);
define('PASS', $db_pass);
define('DB', 'vintagecodingdotnet');
@@ -17,12 +17,13 @@ function get_article_cards()
{
$conn = mysqli_connect(HOST, USER, PASS, DB);
/*
* $query = 'SELECT * FROM articles;';
*
* $results = mysqli_query($conn, $query);
* while ($row = mysqli_fetch_row($results)) {
* echo $row['article_name'];
* }
*/
$query = 'SELECT * FROM accounts;';
$results = mysqli_query($conn, $query);
echo '<pre>';
while ($row = mysqli_fetch_array($results)) {
print_r($row);
echo '<br>';
}
echo '</pre>';
}