Database Values

Hi All

The code shown below works without problem however it’s not doing what I want it to do. When I click on the links it stays on the home page, there are values in the database, I want it to load up the page, at id = 1 etc.

Any help?

	<?php
	
		$connect = require_once('connections/config.php'); 
    
	
	//Connect to mysql server
	$link = mysql_connect($hostname_ilikeyours, $username_ilikeyours, $password_ilikeyours);
	if(!$link) {
		die('Failed to connect to server: ' . mysql_error());
	}
	
	//Select database
	$db = mysql_select_db($database_ilikeyours);
	if(!$db) {
		die("Unable to select database");
	}
		
$result = mysql_query("SELECT * FROM co_pages");

while($row = mysql_fetch_array($result))
  {
  echo '<ul>';
  echo '<li><a href=?page_id='. $row['page_id'] .'>' . $row['page_title'] .  "</a></li>";
  echo '</ul>';
  }
  ?>

Your problem is here:

while($row = mysql_fetch_array($result))

  {

  echo '<ul>';

  echo '<li><a href=?page_id='. $row['page_id'] .'>' . $row['page_title'] .  "</a></li>";

  echo '</ul>';

  }

  ?>

Your hyperlink does not specify any page to go to, only a page (notice the href=?page_id)

Everything after the ? are variables, to move to another page you need something before the ? So what you are doing is loading the same page and sending it the page_id variable

How would I do this?