diff --git a/htdocs/assets/dataset.json b/htdocs/assets/dataset.json new file mode 100644 index 0000000..c28e4ba --- /dev/null +++ b/htdocs/assets/dataset.json @@ -0,0 +1,5 @@ +{ + "email": "mailto:hey@neosubhamoy.com", + "chat": "https:\/\/www.t.me\/neo_subhamoy", + "sources": "https:\/\/github.com\/neosubhamoy\/neosubhamoy-portfolio" +} \ No newline at end of file diff --git a/htdocs/core/query_functions.php b/htdocs/core/query_functions.php index 4996a3b..323b78b 100644 --- a/htdocs/core/query_functions.php +++ b/htdocs/core/query_functions.php @@ -6,13 +6,6 @@ function fetch_all_records($conn, $table_name) { return $result; } -//function to fetch a single record of the given table, cloumn and it's value -function fetch_a_record($conn, $table_name, $column_name, $column_value) { - $sql = "SELECT * FROM $table_name WHERE $column_name = '$column_value'"; - $result = $conn -> query($sql); - return $result; -} - //function to create an array of all unique project years function create_project_years_array($conn) { $sql = "SELECT DISTINCT year FROM projects ORDER BY year DESC"; @@ -68,6 +61,16 @@ function fetch_page_title($conn, $page_name) { } } +//function to fetch page title +function fetch_quick_action_link($conn, $action_name) { + $sql = "SELECT link FROM quick_actions WHERE name = '$action_name'"; + $result = $conn -> query($sql); + if($result -> num_rows > 0){ + $row = $result -> fetch_assoc(); + return $row['link']; + } +} + //---functions to fetch search results starts here--- //from projects table function fetch_search_results_projects($conn, $keyword) { diff --git a/htdocs/core/write_dataset.php b/htdocs/core/write_dataset.php new file mode 100644 index 0000000..8c29877 --- /dev/null +++ b/htdocs/core/write_dataset.php @@ -0,0 +1,13 @@ + fetch_quick_action_link($conn, "Send Email"), + 'chat' => fetch_quick_action_link($conn, "Chat Online"), + 'sources' => fetch_quick_action_link($conn, "Source Code"), + ); + + $json_data = json_encode($data, JSON_PRETTY_PRINT); + $json_file_path = 'assets/dataset.json'; + file_put_contents($json_file_path, $json_data); +} +?> \ No newline at end of file diff --git a/htdocs/home.php b/htdocs/home.php index 26b5d03..0700008 100644 --- a/htdocs/home.php +++ b/htdocs/home.php @@ -6,6 +6,8 @@ $dotenv->load(); require 'core/connection.php'; require 'core/host_config.php'; require 'core/query_functions.php'; +require 'core/write_dataset.php'; +write_dataset($conn); ?>