NavigationNavigation

  Main Menu

Home: Development: Php: Navigation: Jump
Jump to page using php's header function. Use this to redirect a page based on an id held in a table.

$db_name = "yourdatabasename";
$table_name = "redirects";

$cnx = mysql_connect("localhost", "dbname", "pwd") 
or die("Couldn't connect.");

$db = mysql_select_db($db_name, $cnx)
or die("Couldn't select database.");

$sql = "SELECT id, address FROM $table_name
WHERE id = '$id'";

$result = mysql_query($sql,$cnx)
or die("Couldn't execute query.");

while ($row = @mysql_fetch_array($result)) {
$id = $row["id"];
$address = $row["address"];
}

header("location: $address");