function getNews($limit, $id){
global $mysqli;
connectDB ();
if($id)
$where = "WHERE `id` = ".$id;
$result = $mysqli->query("SELECT * FROM `tovar` WHERE `categories` = 'watch' ORDER BY `id` DESC LIMIT $limit");
closeDB ();
if(!$id)
return resultToArray($result);
else
return $result->fetch_assoc();
}
function getNews($limit, $id){
global $mysqli;
connectDB ();
if($id)
$where = "WHERE `id` = ".$id;
$result = $mysqli->query("SELECT * FROM `tovar` WHERE `categories` = 'watch' $where ORDER BY `id` DESC LIMIT $limit ");
closeDB ();
if(!$id)
return resultToArray($result);
else
return $result->fetch_assoc();
}
function getNews($limit, $id, $name){
global $mysqli;
connectDB ();
if($id)
$where = "WHERE `id` = ".$id;
$result = $mysqli->query("SELECT * FROM `tovar`
WHERE $where AND ORDER BY `id` DESC LIMIT $limit AND `categories` = $name");
closeDB ();
if(!$id)
return resultToArray($result);
else
return $result->fetch_assoc();
}
<!DOCTYPE html>
<html lang="ru">
<head>
<?php
require_once "func/func.php";
$tovar = getNews(9, $id, 'watch');
require_once "blocks/head.php";
?>