Results 1 to 8 of 8

Thread: Linking System

  1. #1
    Registered Mike's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    2,755

    Linking System

    Hi all,

    Using PHP, I would like to create a similar linking system to the one used on this site. So each link is entered into a database, given an id, and linked to like "out.php?id=4" or something.

    I haven't used MySQL for ages, so I'm not completely sure how to do it. I think it would involve a for statement with mysql_num_rows, something like:

    PHP Code:
    $result mysql_query("SELECT * FROM table"$dbcnx) ;

    for (
    $x0$x mysql_num_rows($result); $x++)
    {
        
    $row mysql_fetch_assoc($result) ;

        echo (
    "<a href=\"out.php?id=") ;
        echo (
    $row['ID']) ;
        echo (
    "\">") ; 
    As I said, it's a long time since I last used MySQL and PHP together, so chances are that's probably wrong.

    Please could anyone give me any advice on an easier way or anything?

    Thanks a lot,
    Mike
    Don't you just love free internet games ?

  2. #2
    Senior Member chromate's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    2,348
    I'm not sure exactly what you're trying to do. Your code will produce a list of href tags. 1 for each table row.

    If you're after the code for the "out.php" script, it would be something like:

    PHP Code:

    $sql 
    "SELECT url FROM links_table WHERE id = '$id'";
    $result mysql_query($sql$db);

    if(
    $result) { 
       
    $url mysql_result($result0);
       
    header("location: $url");
    } else {
       echo 
    "ID not found";

    Or something like that anyway.

  3. #3
    Registered Mike's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    2,755
    Yeh, I see what you mean. I got it from another script I did sometime last year.

    Anyway, I will have another bash with your idea...

    Thanks a lot,
    Mike
    Don't you just love free internet games ?

  4. #4
    Registered Mike's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    2,755
    By the way, does the header() function work in all browsers?

    Thanks,
    Mike
    Don't you just love free internet games ?

  5. #5
    Administrator Chris's Avatar
    Join Date
    Feb 2003
    Location
    East Lansing, MI USA
    Posts
    7,055
    yes
    Chris Beasley - My Guide to Building a Successful Website[size=1]
    Content Sites: ABCDFGHIJKLMNOP|Forums: ABCD EF|Ecommerce: Swords Knives

  6. #6
    Registered Mike's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    2,755
    Thanks
    Don't you just love free internet games ?

  7. #7
    Registered Mike's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    2,755
    Just to let everyone know, I got it sorted through chromate's code...

    Thanks chromate
    Don't you just love free internet games ?

  8. #8
    Senior Member chromate's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    2,348
    no probs

Similar Threads

  1. Has anyone dealt with Cart32 online ordering system?
    By LMolineux in forum HTML, CSS, Layout, and Design
    Replies: 2
    Last Post: 04-30-2004, 07:44 AM
  2. Cross linking sites with javascript
    By Pietertje in forum Search Engine Optimization
    Replies: 6
    Last Post: 04-25-2004, 12:36 PM
  3. Google starting webmail system?
    By X Q mano in forum General Chat
    Replies: 13
    Last Post: 04-02-2004, 04:56 AM
  4. Navigation and internal linking structure...
    By tragu in forum Search Engine Optimization
    Replies: 3
    Last Post: 09-22-2003, 12:16 PM
  5. linking to morever news feed ?
    By s2kinteg916 in forum Search Engine Optimization
    Replies: 0
    Last Post: 07-23-2003, 04:39 PM

Bookmarks

Posting Permissions

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