# Get contents of processed information from news.inc.php to index.php

**URL:** <https://forum.kirupa.com/t/get-contents-of-processed-information-from-news-inc-php-to-index-php/252290>\
**Category:** programming\
**Created:** [February 18, 2008, 7:17pm UTC](https://forum.kirupa.com/t/get-contents-of-processed-information-from-news-inc-php-to-index-php/252290 "2008-02-18T19:17:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![imagined](https://avatars.discourse-cdn.com/v4/letter/i/a87d85/32.png) [@imagined](https://forum.kirupa.com/u/imagined)\
**Post date:** [February 18, 2008, 7:17pm UTC](https://forum.kirupa.com/t/get-contents-of-processed-information-from-news-inc-php-to-index-php/252290/1 "2008-02-18T19:17:03Z")

</div>

I have this file that gets a list of news articles. I named it news.inc.php Now, I try to call this file from another file and it prints out the code instead of the list of articles. Is there a way I could do this? I tried fread, fopen and get\_file\_contents but doesn’t seem to work.

Can anyone please help me?

**Function**

```php

function news($tablename, $title, $content, $date)
{
	$list = '<div style="border:1px solid #CCC;">';	
	$query = 'SELECT * FROM '.$tablename;
	$result = mysql_query($query);
	if(!$result)
	{
		return 'Query failed on select: '.mysql_error();
		exit();
	}
	while($row = mysql_fetch_array($result))
	{
		$list .= '<p><a href="news.php?id="'.$row['id'].'>'.$row[$title].'</a><br />';
		list($year, $month, $day)=split('-', $row[$date]);
		$list .= date('F j, Y', mktime(0,0,0,$month,$day,$year)).'</p>';
	}
	$list .= '</div>';
	return $list;
}

```

news.inc.php

```php
$tablename = 'news';

$title = 'subject';
$content = 'content';
$date = 'datemodified';

news($tablename, $title, $content, $date);

```
