-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch.php
More file actions
31 lines (23 loc) · 718 Bytes
/
fetch.php
File metadata and controls
31 lines (23 loc) · 718 Bytes
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
<?php
function GenericFetchData($table, $orderby)
{
$db_host="localhost";
$db_user="root";
$db_pass="password";
$db_name="db";
$con = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
if(!$con){
die("connection failed : ". mysqli_connect_error());
}
$query = "SELECT * FROM $table ORDER BY $orderby asc";
$stmt=mysqli_query($con,$query) or die(mysqli_error($con));
if(mysqli_num_rows($stmt) > 0)
{
return $stmt;
}
else
{
echo "No data";
}
}
?>