How do i create a small script for links

Discussion in 'PHP' started by ztealmax, Nov 29, 2006.

  1. #1
    Hi im kinda new at this i would like to create a small script for links
    on my main page for example:

    Home
    News
    etc....

    [​IMG]
    so it saves the info entered like on the pic to a simple text file, im not using SQL.

    For example if link name is home and url is index.php save link as home.txt and place url inside it.

    If that works how do i create a small page to read all files in directory links/
    and places them on the small link menu?

    if you dont understand what i am after place ask me ;)

    Im n0ob at this

    //Cheers
    Martin
     
    ztealmax, Nov 29, 2006 IP
  2. adsblog

    adsblog Active Member

    Messages:
    659
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    70
    #2
    fopen() ;

    Open your desired file ( if file doesn't exist ..create it ) .
    fwrite();
    use this function to write your information to a file . ( file pointed as a handle )

    Now you need a function to split content of file with special chars (e.g : ' or , or | )
     
    adsblog, Nov 30, 2006 IP
  3. crazyden

    crazyden Guest

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Why do not put this to PHP file, and edit it from there. IF you want to administrate it - you'd better use MySQL database for storage
     
    crazyden, Dec 1, 2006 IP
  4. adsblog

    adsblog Active Member

    Messages:
    659
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    70
    #4
    yea .
    Text-File DB is dangerous and hard to programming .
    post here if you want use mysql . we can help you .
     
    adsblog, Dec 2, 2006 IP
  5. CodyRo

    CodyRo Peon

    Messages:
    365
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It's not really hard or "dangerous".. assuming it's just for links on your main page I see no real problem with it.. but either way it's not hard to program.

    Just have php write to a text file..

    
    $fp = fopen('links.txt', 'a+');
    $link = "<a href='http://" . $_POST['url'] . "'>". $_POST['title'] . "</a><br />";
    
    fwrite($fp, $link);
    
    PHP:
    Just a quick example, obviously change depending on your needs.
     
    CodyRo, Dec 2, 2006 IP
  6. crazyden

    crazyden Guest

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Cool, but what if you need tyo change the look of the links, and they are all just hard-coded in that text-file
     
    crazyden, Dec 3, 2006 IP