Jump to content

Displaying part news one 1 page and full on another


Boxerman

Recommended Posts

I think will do it...

<?php 
include("include/config.inc.php"); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
<title></title>
<script language='javascript' type='text/javascript'>
<!--
var win=null;
function NewWindow(mypage,myname,w,h,pos,infocus){
if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=yes,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings);
win.focus();}
// -->
</script> 
</head>
<body>
<div id="header"></div>
<div id="container">
<ul id="topmenu">
	<li><a href="index.php">Home index</a></li>
	<li>-</li>
	<li><a href="contact.php">Contact Us</a></li>
	<li>-</li>
	<li><a href="report.php">Report A Error</a></li>
</ul>
<div id="menucontent">
	<div id="links">
		<div id="menu">
			<h3>Menu</h3>
			<ul id="linksmenu">
				<li><a href="index.php">Home</a></li>
				<li><a href="request.php">Request</a></li>
				<li><a href="chart.php">Chart</a></li>
				<li><a href="javascript:NewWindow('miniversie.php','miniversie','250','320','custom','front');"> mini versie </a></li> 
			</ul>
			<div id="menulast"></div>
		</div>
		<div id="menu">
			<h3>Media</h3>
			<ul id="linksmenu">
				<li><a href="music.php">Music</a></li>
				<li><a href="videos.php">Videos</a></li>
				<li><a href="http://facebook.com/truvibefm" target="_blank">Facebook</a></li>
				<li><a href="javascript:NewWindow('miniversie.php','miniversie','250','320','custom','front');">Player</a></li> 
			</ul>
			<div id="menulast"></div>
		</div>
		<div id="menu">
			<h3>Link</h3>
			<ul id="linksmenu">
				<li></li>
				<li></li>
				<li></li>
			</ul>
			<div id="menulast"></div>
		</div>
	</div>
	<div id="rechts">
		<div id="rechtscontent">
			<p>
			<?PHP
			/*  function to return the first N words of a string */
			function shorten_string($string, $wordsreturned) {
				$retval = $string;
				$array = explode(" ", $string);
				if (count($array)<=$wordsreturned) {
					$retval = $string;
				}else{
					array_splice($array, $wordsreturned);
					$retval = implode(" ", $array)." ...";
				}
				return $retval;
			}
			/* check to see if an article has been selected */
			if(!$_GET['id']) {
				$id = 0;
			}else{
				$id = (int) $_GET['id'];
			}
			/* set the number of words for the brief */
			$N = 15;
			/* if id is set display the news */
			if($id>0) {
				$query = "SELECT * FROM news WHERE id='$id'";
				$result = mysql_query($query);
				$row = mysql_fetch_array($result);
				$title = $row['title'];
				$posted_by = $row['postedby'];
				?>
				Title: <?PHP echo $title; ?> <br>
				Posted By: <?PHP echo $posted_by; ?> <br>
				<?PHP
				echo $row['text']
				?>
				<br>
				<a href="story.php?id=0">Back to news listings</a>
				<?PHP
			}else{
				/* create query */
				$query = "SELECT * FROM news ORDER BY id";
				/* execute the query */
				$result = mysql_query($query);
			while($row=mysql_fetch_array($result)) {
				$title = $row['title'];
				$posted_by = $row['postedby'];
				$brief = shorten_string($row['text'], $N);
				?>
				Title: <?PHP echo $title; ?> <br>
				Posted By: <?PHP echo $posted_by; ?> <br>
				<a href="story.php?id=<?PHP echo $row['id']; ?>"><?PHP echo $brief; ?></a>
				<?PHP
			}
			?>
		</div>
	</div>
</div>
</div>
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.