diff --git a/.gitignore b/.gitignore index 0b76939..ffd6450 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -*/.env +*.env /vendor/ diff --git a/includes/functions.php b/includes/functions.php new file mode 100644 index 0000000..e69de29 diff --git a/includes/sql.php b/includes/sql.php index 9830455..2030961 100644 --- a/includes/sql.php +++ b/includes/sql.php @@ -1,5 +1,28 @@ 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']; + * } + */ } -?> diff --git a/index.php b/index.php index ca79af3..756646f 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,5 @@ Hello cruel world!'; - include_once('includes/components/foot.php'); -?> +include_once ('includes/components/head.php'); +include_once ('includes/sql.php'); +get_article_cards(); +include_once ('includes/components/foot.php'); diff --git a/scripts/initdb.sh b/scripts/initdb.sh new file mode 100755 index 0000000..8d47ac8 --- /dev/null +++ b/scripts/initdb.sh @@ -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