Help: Hyperlink php help...

Discussion in 'PHP' started by Skillman13, Oct 24, 2009.

  1. #1
    I have this code which is not working, and I need to know why, can anyone fix this or explain what is wrong?

    (I am trying to get it to read a text file -which is a URL, in a record and display it as a hyperlink on the .php page -If i am doing this in the worng way, -or there is a simpler way, please do explain)...

    $linkquery = ("SELECT BuyLink FROM 'Gamepage'");
    $resultlink= mysql_query($linkquery);

    while($row = mysql_fetch_array($resultlink))
    {
    echo $row['Buylink'];
    echo "<BR>";
    }
    $link = "Test!";
    $list .="<a href=\"$resultlink\" target=\"_blank\">". $link."</a></td>";
    echo $list;

    Thank you very much...

    James,
     
    Skillman13, Oct 24, 2009 IP
  2. Skillman13

    Skillman13 Peon

    Messages:
    229
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I also tried this,

    -It didn't work =/

    $linkquery = ("SELECT BuyLink FROM 'Gamepage'");
    $resultlink= mysql_query($linkquery);

    while ($row = mysql_fetch_array($resultlink)) {
    $str = '<a href="' . $row['$resultlink'] . '"></a><br>';
    echo $str;
    }
     
    Skillman13, Oct 24, 2009 IP
  3. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Try this

    $linkquery = "SELECT `BuyLink` FROM `Gamepage`";
    $resultlink = mysql_query($linkquery) or die(mysql_error());
    
    while ($row = mysql_fetch_array($resultlink)) {
    	echo $row['Buylink'].'<br />';
        $link = "Test!";
        $list .= '<a href="'.$row['Buylink'].'" target="_blank">'.$link.'</a></td>';
    }
    echo $list;
    PHP:
     
    JAY6390, Oct 24, 2009 IP
  4. Skillman13

    Skillman13 Peon

    Messages:
    229
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It sorta works, it comes up with... 'Test!' as a link to the same page in blank (doesn't take you anywhere) =/

    Any more advice? or do u need more info or whatever? =/
     
    Skillman13, Oct 24, 2009 IP
  5. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Would really need more info on the table. What sort of data do you get back from it. Three simple things I need to know from the WWW rule....
    1. What did you try?
    2. What did you get?
    3. What did you expect?
     
    JAY6390, Oct 24, 2009 IP
  6. Skillman13

    Skillman13 Peon

    Messages:
    229
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Ok well...
     
    Skillman13, Oct 24, 2009 IP
  7. Skillman13

    Skillman13 Peon

    Messages:
    229
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    @mysql_connect($host,$user,$pass);
    @mysql_select_db($db) or die ('Fail');

    $dToday = date('Y-m-d');
    $query = ("SELECT * FROM Gamepage WHERE releasetime > '$dToday'");
    $result= mysql_query($query);

    while($row = mysql_fetch_array($result))
    {
    echo $row['id'] . ' - Released on: ' . $row['releasedate'] . $row['BuyLink'];
    echo "<BR>";

    }
    $linkquery = "SELECT `BuyLink` FROM `Gamepage`";
    $resultlink = mysql_query($linkquery) or die(mysql_error());

    while ($row = mysql_fetch_array($resultlink)) {
    echo $row['Buylink'].'<br />';
    $link = "Test!";
    $list .= '<a href="'.$row['Buylink'].'" target="_blank">'.$link.'</a></td>';
    }
    echo $list;

    echo date('d/m/y');
    ?>

    Is the complete code for now, -not including database/login stuff...

    Call of Duty Modern Warfare 2 - Released on: 10th November 2009http://www.play.com/Games/Xbox360/4-/8771809/Call-Of-Duty-Modern-Warfare-2/Product.html
    Halo Reach - Released on: 1st November 2009



    Test!Test!Test!24/10/09

    Is the result,
    With 2 records and one with BuyLink...

    Test! is the hyperlink that is supposed to appear, it works but it takes you straight back you to the same page in (_blank) mypagesurl/GAMETAB/test.php

    database = mountgam_Gametab
    table = Gamepage
    fields = id number Picture Description Extra info BuyLink releasedate releasetime
    records = Call of Duty Modern Warfare 2 1 cod6.jpg FTW! Buy from Play.com... http://www.play.com/Games/Xbox360/4-/8771809/Call-Of-Duty-Modern-Warfare-2/Product.html... 10th November 2009 2009-11-10

    Sorry for that bluge of text...


    Do you need any more info?
     
    Skillman13, Oct 24, 2009 IP