# Get url from function and put content into template

**URL:** <https://forum.kirupa.com/t/get-url-from-function-and-put-content-into-template/304196>\
**Category:** programming\
**Created:** [February 3, 2010, 2:35am UTC](https://forum.kirupa.com/t/get-url-from-function-and-put-content-into-template/304196 "2010-02-03T02:35:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![WAcreative](https://avatars.discourse-cdn.com/v4/letter/w/ecd19e/32.png) [@WAcreative](https://forum.kirupa.com/u/WAcreative)\
**Post date:** [February 3, 2010, 2:35am UTC](https://forum.kirupa.com/t/get-url-from-function-and-put-content-into-template/304196/1 "2010-02-03T02:35:31Z")

</div>

Hi,

I have been searching all over the web and every thread in these forums for the issue I am having but I can’t find anything (I’ve done about a billion different google searches).

Here is my issue:

I am creating a pagination type setup with PHP and MySQL through a template. The template loads different content based on what is in the url box in your browser. So if:

```auto
http://www.mysite.com/template.php?=page1

```

…you should get row 1 of table ‘example’ from the database “\_test”. What should happen is column “content” should go into the place where my function:

```auto
<?php get_content(); ?>

```

…is.

My current trial to get the function to work is here:

```auto
function put_header() {
		$p = mysql_query("SELECT $i FROM articles");
		while ($result = mysql_fetch_array($p)) {
		$i = $result['id'];
		}
		
		for($i=0; $i<=0; $i++) {
			if($title .= $i) {
				$url .= "?page=$i";
			} else {
				return 'No content to show';
			}
		}
	}

```

```auto
$title

```

…is actually a short variable of…

```auto
$row['headline']

```

… which basically makes it easier to get the column ‘headline’ from each row in the database table.

So basically I want a navigation on the left of the content that makes the url show up as ?page=$i. $i is row[‘id’] in the same column as ‘headline’ and is an auto\_increment in the table.

Each navigation item will be a link to each ‘id’ and put the ‘headline’ into the template based on the ‘id’ number.

Any help is appreciated as I’ve searched everything for help. If I didn’t explain good enough I will be back online tomorrow to explain more if needed.

THANKS!
