generated from GenerateNU/GenerateHWBase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_data.php
39 lines (34 loc) · 1.25 KB
/
get_data.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
// Database connection parameters
$host = "localhost";
$username = "root";
$password = "usbw";
$database = "test";
// Establishing connection to the database
$mysqli = new mysqli($host, $username, $password, $database);
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
} else {
// Prepare a SQL statement to select data with userName = 'Placeholder'
$selectSql = "SELECT dateTime, muscleData FROM data WHERE userName IN ('Placeholder', '')";
// Execute the query
$result = $mysqli->query($selectSql);
if ($result) {
// Fetch associative array
while ($row = $result->fetch_assoc()) {
$dateTime = $row["dateTime"];
$muscleData = $row["muscleData"];
// Output hidden input fields for dateTime
echo "<input type='hidden' name='dateTime[]' value='$dateTime'>";
// Output the label and input field for username
echo "<label>$dateTime</label><input type='text' name='username[]'><br>";
}
// Free result set
$result->free();
} else {
echo "Error executing query: " . $mysqli->error;
}
// Closing the database connection
$mysqli->close();
}
?>