ohctech_p8/select_habit.php
Dushant Mali 899fb3e65a Upgrade 7 to 8
Upgrade 7 to 8
2024-11-02 18:03:13 +05:30

44 lines
1.1 KiB
PHP

<?php
include('includes/config/config.php');
include('log_entry.php');
$id = $_POST['id'];
$name = $_POST['name'];
$data = array();
if (!empty($id)) {
$query = "select * from habits where habit_id = '$id' ";
if (!$result = @mysqli_query($conn, $query)) {
die(mysqli_error($conn));
}
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$data = $row;
}
} else {
$data['status'] = 200;
$data['message'] = "Data not found!";
}
} else {
$query = "select * from habits where upper(habit)= upper('$name') ";
error_log($query);
if (!$result = @mysqli_query($conn, $query)) {
die(mysqli_error($conn));
}
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
array_push($data, $row);
}
} else {
$data['status'] = 200;
$data['message'] = "Data not found!";
}
$data['count'] = mysqli_num_rows($result);
}
// error_log(print_r($data, true));
echo json_encode($data);