now i have a function in PHP to retrieve data from my database
function get_category_posts($cat_name) {
global $conn;
$sql = "SELECT * from posts where cat_name = '".$cat_name."' order by date desc";
$result = mysqli_query($conn, $sql);
$row = array();
for($i = 0; $i < mysqli_num_rows($result); $i++) {
$row[] = mysqli_fetch_array($result,MYSQL_ASSOC);
}
return $row;
}
and I have a .php file where i'm calling this function
$result = get_category_posts("Актуальные новости");
foreach ($result as $row) {
// do something
}
my db connection
$conn=new mysqli("localhost", "ss", "ss", "s");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
db include
include_once("functions.php");
But the problem is, nothing displayed on my file. Sorry for my bad english ^_^