Files
portfoliowai/models/projects.php
T
2026-06-05 19:19:50 +08:00

34 lines
856 B
PHP

<?php
require_once __DIR__ . "/../config/db.php";
function getProjects($mysqli){
$projects = [];
$sql = "SELECT * FROM projects ORDER BY id DESC";
$result = $mysqli->query($sql);
if ($result && $result->num_rows > 0) {
// Loop through the database rows and push names into the array
while ($row = $result->fetch_assoc()) {
$projects[] = $row;
}
}
return $projects;
}
function getThreeProjects($mysqli){
$projects = [];
$sql = "SELECT * FROM projects ORDER BY id DESC LIMIT 3";
$result = $mysqli->query($sql);
if ($result && $result->num_rows > 0) {
// Loop through the database rows and push names into the array
while ($row = $result->fetch_assoc()) {
$projects[] = $row;
}
}
return $projects;
}
?>