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,
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; }
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:
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? =/
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?
@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?