Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Switching websites using PHP

    I need some advice on users being able to switch to other websites from my own using PHP.

    When you place the mouse on an image in my table grid, at the bottom of the screen you can see the name of my website followed by the unique key identifier, it looks as follows:

    http://www.mysite.com/url.php?id=1

    The field 'id' is the unique key in a sql table. I need some PHP that will pick up the key field 'id' from the screen, read the table using the 'id' key field, and retrieve the contents of the field 'url' from the sql table record. I then need the user to switch automatically to the website indicated by this new url.

    As a user all that should happen is you select the image on the page and you should switch automatically to the website associated with the image.

    Can you assist in the construction of this PHP statement?

    Many Thanks

  • #2
    New Coder
    Join Date
    Jul 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by thinker987 View Post
    I need some advice on users being able to switch to other websites from my own using PHP.

    When you place the mouse on an image in my table grid, at the bottom of the screen you can see the name of my website followed by the unique key identifier, it looks as follows:

    http://www.mysite.com/url.php?id=1

    The field 'id' is the unique key in a sql table. I need some PHP that will pick up the key field 'id' from the screen, read the table using the 'id' key field, and retrieve the contents of the field 'url' from the sql table record. I then need the user to switch automatically to the website indicated by this new url.

    As a user all that should happen is you select the image on the page and you should switch automatically to the website associated with the image.

    Can you assist in the construction of this PHP statement?

    Many Thanks
    I can do this for you. Feel free to PM if you still need help with this.

  • #3
    New Coder
    Join Date
    Jan 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If I understand what you asked it should look something like this...

    PHP Code:

    // this file should go at the top of url.php

    if (isset($_REQUEST['id']))
    {
      
    $sql mysql_query"SELECT `url` FROM `sqltable` WHERE `id`='$_REQUEST[id]' "
                                or die (
    mysql_error());

     
    $row mysql_fetch_array($sql);

     echo 
    '
            <script>
             window.location="$row[url]"
            </script>
          '
    ;

    Let me know if it works
    Last edited by Erockrm1; 01-28-2007 at 10:13 PM.

  • #4
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi all

    Just to confirm, martialtiger has provided some code which resolved this problem, thanks for all of your input

  • #5
    Regular Coder
    Join Date
    Aug 2006
    Location
    UK, London, Dartford
    Posts
    221
    Thanks
    3
    Thanked 14 Times in 14 Posts
    Or in the loop use header("Location: 'URL BY ID'") function, instead of script....


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •