This commit is contained in:
2025-03-05 09:38:25 -07:00
parent b453739630
commit 8d244e586d
5 changed files with 38 additions and 8 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
*/.env
*.env
/vendor/
View File
+25 -2
View File
@@ -1,5 +1,28 @@
<?php
function get_article_cards() {
// phpdotenv initialization
require_once 'vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..');
$dotenv->safeLoad();
// Use environment variables for the database password and IP address.
// $db_user = $_ENV['DATABASE_USER'];
$db_pass = $_ENV['DATABASE_PASSWORD'];
define('HOST', 'localhost');
define('USER', 'root');
define('PASS', $db_pass);
define('DB', 'vintagecodingdotnet');
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'];
* }
*/
}
?>
+2 -2
View File
@@ -1,5 +1,5 @@
<?php
include_once ('includes/components/head.php');
echo '<h1>Hello cruel world!</h1>';
include_once ('includes/sql.php');
get_article_cards();
include_once ('includes/components/foot.php');
?>
+7
View File
@@ -0,0 +1,7 @@
create_db() {
mariadb -u root -p -e "CREATE DATABASE vintagecodingdotnet;"
mariadb -u root -p -e "USE vintagecodingdotnet; CREATE TABLE articles (article_id INT PRIMARY KEY AUTO_INCREMENT, article_name VARCHAR(255) NOT NULL);"
mariadb -u root -p -e "USE vintagecodingdotnet; INSERT INTO articles (article_name) VALUES ('test'), ('another test'), ('a third test');"
}
create_db