+ Reply to Thread
Results 1 to 3 of 3

Thread: Dynamic Links?

  1. #1
    totalmockery is offline x10Hosting Member totalmockery is an unknown quantity at this point
    Join Date
    Jul 2009
    Location
    Canada
    Posts
    27

    Dynamic Links?

    Hi there,

    I'm not 100% sure what to call this, I think it's Dynamic Links.
    I want to know how to create links that produce urls like this:

    http://www.example.com/news/?subtopic=news

    For the life of me, and google, I can't figure this out. Mainly because I don't know what the technical term is for it.

    Any help is greatly appreciated.


    Cheers,

    Joel

  2. #2
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: Dynamic Links?

    A dynamic link is one that is created as a result of the original url + a dynamic element, such as the addition of an id number.

    For instance, you may have a standard url link such as http://www.yoursite.com/mypersonal details.php

    The trouble is that if "someone" is logged in and you follow that link, the mypersonaldetails page has no idea who it is meant to look for.

    Sooo.. dynamics.. the following is an example created in php.

    Example for http://www.yoursite.com/mypersonaldetails.php?id=345

    Create a recordset of users on a page you are linking from.

    Create dynamic repeating table on the same page (do..while)

    In each loop of $row, add the following..

    PHP Code:
    <a href="mypersonaldetails.php?id=<?php echo $row_userrecordset['id'];?>">link text</a>
    This link is built in two parts - the first part which remains static. The you add "?" which allows the addition of a second identifier or any variable for that matter. The you specify what variable to send.. the "id=" part. Then generate the id created on that row - which is echo'd in php from the recordset.

    When you click on this link.. it is dynamic and will carry the id to the next oage, where you capture that same variable and use it to create a new recordset on the new page.

    i.e.

    PHP Code:
    <?php 
    $new_id
    =$_GET['id'];
    ?>
    This piece of code will obtain the variable from the url ($_GET) and assign it to the new variable ($new_id).

    You can pass any number of variables in one url. Commonly, the current page is passed as a variable so that the new page can re-direct to the previous one.

    Hope this explains a bit. :S

  3. #3
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Dynamic Links?

    Freecrm shows you how to do what you want, but if you want to know what you're doing, read on. The portion of the URI after the question mark is called a "query string". The elements of a query string are usually "field-value pairs" of the form "field=value" or just field names with no value, but they could have any format you wish. Of course, if you're using an ad hoc format, you're basically sending field names that you'll have to parse to get the data in the format you want. When you're dealing with a query string of the traditional field-value pairs, the pairs are also called "URL parameters". Note the difference between a query string and URL parameters: the URL parameters are the result of parsing the query string.

    More generally, what you're dealing with is termed "form input" or "user input". This comes up in the very important directive "always sanitize user input" ([2]). I don't know how much you know about HTTP, but there are two methods HTTP methods that can send user input: GET and POST. Each uses a different technique to transmit user input, but any script you write to process the data won't see much difference. The GET request transmits input using the query string in a URL. POST is used by forms (though they can also use GET), hence the term "form input". The two methods are also the origin of the names for $_GET and $_POST in PHP.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. Turn your links into cash - LinkyBank.com
    By linkybank in forum Earning Money
    Replies: 4
    Last Post: 06-26-2009, 09:56 AM
  2. Múltiples links de cuentas de alojamiento / foro
    By Kansy in forum Noticias y Anuncios
    Replies: 4
    Last Post: 03-31-2009, 05:20 PM
  3. Ucash.in - Earn Money from links.
    By fabionj in forum Earning Money
    Replies: 1
    Last Post: 03-30-2008, 05:49 PM
  4. Replies: 0
    Last Post: 03-05-2008, 08:30 PM
  5. Urgent help please!
    By retro-bliss in forum Free Hosting
    Replies: 2
    Last Post: 10-25-2007, 03:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers