Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: PHP Links

  1. #1
    Join Date
    May 2007
    Location
    England, UK
    Posts
    235
    Thanks
    3
    Thanked 6 Times in 6 Posts

    Question PHP Links

    Probably a simple answer for those of you that know, but i'm trying to display a page of data from a MySQL database using PHP.

    Can i send information from anything other than a form

    e.g.

    In a form I would do the following:
    HTML Code:
    <form action="mypage.php" method="post">
           <input type="text" name="myvalue" />
           <input type="Submit" />
    </form>
    can I submit a single value using a link

    e.g.
    HTML Code:
    <a href="mypage.php" name="myvalue">
    Last edited by jc_gmk; 06-14-2007 at 11:45 AM.

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    yes you can, but you would need to be more specific in naming the file. when you submit to a form there is extra data that is sent with it depending on what method you use (eg post / get), if you wish to just use a link, then you really need to be alot more specific in the url.

    Take this for example
    [code]
    <form action="process.php" method="get">
    Name: <input type="text" name="user" value="CLIENT_NAME" />
    <input type="submit" value="submit" />
    </form>

    you would then grab that info in your php process.php file by using this
    PHP Code:
    $name $_GET['user'];
    ...
    ... 
    to accomplish that with just a link you would need to hard code the "user" in this case, which would look something like
    Code:
    <a href="process.php?user=CLIENTNAME">link title</a>
    you would then grab that info in your php process.php file by using this
    PHP Code:
    $name $_GET['user'];
    ...
    ... 

    so if what you are attempting to do is just submit a constant value then yes you can use just a link, however if you are trying to obtain some type of resource / content from a client/user then I would suggest that you use the form method.

    either way you would still need to handle the mysql inside the php file.

  3. #3
    Join Date
    May 2007
    Location
    England, UK
    Posts
    235
    Thanks
    3
    Thanked 6 Times in 6 Posts

    Default

    Works a treat!!
    Thanks!

  4. #4
    Join Date
    May 2007
    Location
    England, UK
    Posts
    235
    Thanks
    3
    Thanked 6 Times in 6 Posts

    Default

    Following on from that question, I have now created a page that calls different data depending on what link you click.

    Is there anyway that if one of these links are clicked
    it is then highlighted to let the user know what the are looking at

  5. #5
    Join Date
    Jun 2007
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    If you mean the something like the link, and maybe its background colour changing, see here.

  6. #6
    Join Date
    May 2007
    Location
    England, UK
    Posts
    235
    Thanks
    3
    Thanked 6 Times in 6 Posts

    Default

    I am able to currently using those methods anyway,

    what I need to know is; can I get the link to stay highlighted the whole time they are veiwing a dynamic page

    e.g.
    Code:
    page1  |  page2  |  page3  |  page 4
    
    This content was produced by clicking page2
    Code:
    page1  |  page2 |  page3   |  page 4
    
    This content was produced by clicking page3

  7. #7
    Join Date
    Jun 2007
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hmm. Pretty much what you get on a good tabbed menu system, which I am digging about for at the moment. Here's one example. As for generation of the tabs through php, here's something I thought I might look at when I get a round tuit (in short supply at the moment). May help you?

  8. #8
    Join Date
    May 2006
    Location
    New York City
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This should produce the effect . . .

    PHP Code:
    //list of variables
    $list_of_variables = array("var1" => "page one",
                               
    "var2" => "page two",
                               
    "var3" => "page three",
                               
    "var4" => "page four");

    $tmp = array();
    foreach (
    $list_of_variables as $var => $page_name) {
         if (
    $_GET['my_var'] == $var) {
              
    $tmp[] = "<font color='red'>$page_name</font>";
         } else {
              
    $tmp[] = "<a href='mypage.php?my_var=$var'>$page_name</a>";
         }
    }

    echo(
    implode(" | "$tmp);
    echo(
    "<br/>You've reached this page by clicking on ".$_GET['my_var']); 
    so then if the person clicks on
    HTML Code:
    <a href='mypage.php?my_var=var3'>page three</a>
    they'll get this:

    page one | page two | page three | page four
    You've reached this page by clicking on var3

    Where, of course, pages one two and four are links but page three is not.

  9. #9
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    <font> tags have been depreciated by the W3C Standards Committe. Use a <div > or <p> or <span> tag then use a CSS style to mark it up

  10. #10
    Join Date
    Jun 2007
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Kosi, nice. I have bookmarked this thread.

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
  •