arnada Posted October 24, 2007 Share Posted October 24, 2007 Hej hej, jag har letat på nätet en massa nu efter ett script som ansluter mot en databas som koden nedan. SELECT id from redirect where id = 1 vad jag vill ha ut nu är när id = 1 så ska redirect till sida 1 köras om det är id = 2 så ska redirect till sida 2 köras. Är detta möjligt? Är inte så bra på php :- Men har ganska lätt för att förstå koden ;D Skicka / skriv gärna kod snippets som jag kan exprementera med. EDIT! Jag testade med ett script jag skrev själv, men det var 100% chansning ;D <?php include '../config/config.php'; include '../config/opendb.php'; $id = $_GET['id']; $id = "SELECT id from redirect where id = 1"; if ($id == "0") {$link = 'http://www.google.se';} //Default Blank if ($id == "1") {$link = 'http://www.megagames.com';} // COMMENT header('HTTP/1.1 301 Moved Permanently'); // Clean 301 header header("Location: $link"); // Jump to the link exit(); ?> Tack Quote Link to comment Share on other sites More sharing options...
Venoms Posted October 24, 2007 Share Posted October 24, 2007 Ett förslag... <?php $links = array( "1" => "http://www.itpoolen.se", "2" => "http://www.alltomxp.se", "3" => "http://www.microsoft.com", "4" => "http://www.ubuntu-se.org/drupal/" ); header("Location:".$links[$_GET['site']]); exit; ?> Funkar såhär: skriv bara http://dinsida.se/redirect.php?site=1 och du blir skickad till http://www.itpoolen.se Quote Link to comment Share on other sites More sharing options...
arnada Posted October 25, 2007 Author Share Posted October 25, 2007 Tack Venoms men tyvärr är det inte så jag vill ha det :-[, Jag vill styra vilken sida som skall visas genom mysql databasen. Går detta? ??? Quote Link to comment Share on other sites More sharing options...
Venoms Posted October 25, 2007 Share Posted October 25, 2007 Det var synd... Kolla om du kan använda infot här på något sätt... http://www.itworld.com/AppDev/4072/LWD0105...n4/pfindex.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.