50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
require_once __DIR__ . "/../config/db.php";
|
|
|
|
function getTechStack($mysqli){
|
|
$sql = "SELECT tech_name FROM techstack";
|
|
$result = $mysqli->query($sql);
|
|
|
|
$techs = [];
|
|
if ($result) {
|
|
// Loop through the database rows and push names into the array
|
|
while ($row = $result->fetch_assoc()) {
|
|
$techs[] = $row['tech_name'];
|
|
}
|
|
}
|
|
|
|
return $techs;
|
|
}
|
|
|
|
function getTechStackRaw($mysqli) {
|
|
$sql = "SELECT * FROM techstack ORDER BY id ASC";
|
|
$result = $mysqli->query($sql);
|
|
$techs = [];
|
|
if ($result) {
|
|
while ($row = $result->fetch_assoc()) {
|
|
$techs[] = $row;
|
|
}
|
|
}
|
|
return $techs;
|
|
}
|
|
|
|
function addTechStackItem($mysqli, $tech_name) {
|
|
$sql = "INSERT INTO techstack (tech_name) VALUES (?)";
|
|
$stmt = $mysqli->prepare($sql);
|
|
if ($stmt) {
|
|
$stmt->bind_param("s", $tech_name);
|
|
return $stmt->execute();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function deleteTechStackItem($mysqli, $id) {
|
|
$sql = "DELETE FROM techstack WHERE id = ?";
|
|
$stmt = $mysqli->prepare($sql);
|
|
if ($stmt) {
|
|
$stmt->bind_param("i", $id);
|
|
return $stmt->execute();
|
|
}
|
|
return false;
|
|
}
|
|
?>
|