Problem with creating hyperlinks

Discussion in 'PHP' started by chetandhiman, May 18, 2010.

  1. chetandhiman

    chetandhiman Member

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #21
    Here is the code that is working perfect:

    $username= $results[$i]['Name'];
    $url = $results[$i]['Website'];
    $add = "http://";
    $check_url = substr($url,0,7);
    if($check_url=="http://") {
    $output = "<a href=\"{$url}\">$username</a> said:". "<BR>";
    }
    else {
    $url = ($add.$url); }
    $output = "<a href=\"{$url}\">$username</a> said:". "<BR>";

    Now it doesn't matter if user puts http:// or not :)
     
    chetandhiman, May 21, 2010 IP
  2. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #22
    Well using loops you can solve easily

    if they are in multiples then Switch case is best! :)
     
    roopajyothi, May 21, 2010 IP
  3. chetandhiman

    chetandhiman Member

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #23
    Thanks for this extra tip:)
    Now could you please guide me how I can add 'Edit Feature' to my Comment Script so that I can edit comments directly from browser.
     
    Last edited: May 21, 2010
    chetandhiman, May 21, 2010 IP