emem
Новичок
Дата регистрации:
23.04.2013 00:40:17
Сообщений: 3
Привожу код:
-------------------
article.php
-------------------
<?php
require_once "start.php";
$article = getArticle($_GET["id"]);
$id=$article[$i]["id"];
$title=$article[$i]["title"];
$full_text=$article[$i]["full_text"];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $title;?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="css/main.css">
</head>
<body>
<div id="wrapper"> <!--обертка сайта в блок div-->
<div id="header">
<?php
require_once "blocks/top.php";
?>
</div> <!--шапка сайта-->
<?php
require_once "blocks/bannersL.php";
?>
<?php
require_once "blocks/bannersR.php";
?>
<div id="content" class="article">
<?php
require_once "blocks/full_article.php";
?>
</div> <!--контент-->
<?php
require_once "blocks/footer.php";
?>
</div>
</body>
</html>
-------------------
full_article.php
-------------------
<div class="article">
<h1><?php echo $title;?></h1>
<p class="article_img">
<img src="img/article_<?php echo $id;?>.png" alt="<?php echo $title;?>"/>
</p>
<p>
<?php echo $full_text;?>
</p>
</div>
-------------------
start.php
-------------------
<?php
require_once "lib/functions.php";
?>
-------------------
functions.php
-------------------
<?php
$mysqli=false;
function connectDB(){
global $mysqli;
$mysqli=new mysqli("localhost", "root", "", "mysite-local"
$mysqli->query("SET NAMES 'utf8'"
}
function resultSetToArray($result_set){
$array=array();
while(($row = $result_set -> fetch_assoc())!= false)
$array[]=$row;
return $array;
}
function getArticle($id){
global $mysqli;
connectDB();
//$result_set = $mysqli->query("SELECT * FROM `articles`"
$result_set = $mysqli->query("SELECT * FROM `articles` WHERE `id`='$id'"
//print_r($result_set);
closeDB();
return $result_set->fetch_assoc();
//return resultSetToArray($result_set);
}
function closeDB(){
global $mysqli;
$mysqli->close();
}
?>