Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ##
- ## news();
- ##
- function news($var) {
- global $page;
- ## Settings
- $db_host = "localhost";
- $db_user = "forum00100";
- $db_pass = "oldies";
- $db_name = "forum00100";
- $db_table = "site_news";
- $news_archive_link = $_SERVER['PHP_SELF'] . '?page=news';
- ## Connect to mysql and gather data
- mysql_connect($db_host,$db_user,$db_pass) or die("Unable to connect to MySQL");
- mysql_select_db($db_name) or die("Unable to select DB");
- ## How many news to output
- if ($var == "all") {
- $query = mysql_query("SELECT id,title,link,text,date FROM `$db_table` ORDER BY `id` DESC");
- } elseif($var != "") {
- $query = mysql_query("SELECT id,title,link,text,date FROM `$db_table` ORDER BY `id` DESC LIMIT $var");
- }
- ## Data gather complete, close MySQL connection
- mysql_close();
- ##
- ## Start news output
- ## link -> title -> text -> date
- ##
- ## create div box
- echo '<div class="left">
- <h1>.News</h1>
- <div id="mainNews">';
- $i = 1;
- while($list = mysql_fetch_array($query)) {
- ## echo all news
- if ($list['link'] == "") {
- $list['link'] = "#";
- }
- do {
- echo '
- <a href="'.$list['link'].'">
- <span class="title">'.$list['title'].'</span>
- <span class="content">'.$list['text'].'</span>
- <span class="date">'.$list['date'].'</span>
- </a>';
- $i++;
- }
- while($i<=0);
- }
- ## close div box
- if ($page == "news") {
- echo '</div>
- </div>';
- } else {
- echo '<a href="'.$news_archive_link.'">News Archive</a>
- </div>
- </div>';
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement