-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
91 lines (84 loc) · 2.48 KB
/
index.php
File metadata and controls
91 lines (84 loc) · 2.48 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
require_once 'db_connect.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Blog In!!!</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="contain">
<div id="header">
<h1><?php echo "$sitename"; ?></h1>
</div>
<div id="menus">
<a href="index.php" target="_self">Home</a>
<?php
/*
Displaying List of Categories from the Table - Category and that is limited to 10
*/
$qry=mysql_query("SELECT * FROM category LIMIT 0, 10", $con);
if(!$qry)
{
die("Query Failed: ". mysql_error());
}
/* Fetching datas from the field "category" and article id is transfered to articles.php file */
while($row=mysql_fetch_array($qry))
{
echo " <a href=articles.php?cat=".$row['category'].">".$row['category']."</a> ";
}
?>
</div>
<div id="r_login">
<img src="images/admin_login.jpg" alt="admin login" height="25" width="20" >
<a href="login.php" target="_self">Admin Login</a>
</div>
<div id="l_space">
<h2>Latest topics:</h2>
<?php
/*
Selecting the last added articles to display in the section - "blog" from the table "articles"
*/
$qry=mysql_query("SELECT * FROM articles order by articles.id DESC LIMIT 0, 5", $con);
if(!$qry)
{
die("Query Failed: ". mysql_error());
}
/* Fetching and dispalying the datas to blog section from the databse table "articles" */
/*
the php in-built function substr() is used to limit the no of characters displayed in blog section to 200 and when "Read more" is clicked article id is transfered through url to articles.php for displaying in full
*/
while($row=mysql_fetch_array($qry))
{
echo "<h2>".$row['title']."</h2>";
echo "<img src=".$row['image']." />";
echo "<p>".substr($row['contents'],0,200)." <a href=articles.php?id=".$row['id']." > Read more..</a></p>";
}
?>
<p> </p>
</div>
<div id="r_space">
<h2>List of Recent Blog::</h2>
<?php
/* Selecting & querying the Table "articles"
in descending order referring to the field "id"
and limiting the number of result to 10 */
$qry=mysql_query("SELECT * FROM articles order by articles.id DESC LIMIT 0, 5", $con);
if(!$qry)
{
die("Query Failed: ". mysql_error());
}
/* Fetching data from the field "title" */
while($row=mysql_fetch_array($qry))
{
echo "<li><a href=articles.php?id=".$row['id'].">".$row['title']."</a></li>";
}
?>
</div>
<div id="footer">
<div align="center"><strong>Powered by Blogin!!! @ 2012</strong></div>
</div>
</div>
</body>
</html>