Hyperlink from database for all gamertags?
I would like to be able to connect to a database with this table...
+----+----------+-----------+
| id | gamertag | timestamp |
+----+----------+-----------+
and then print the hyperlink for each gamertag in the table. I have absolutely no idea where to start...
<?php
@mysql_connect("localhost","","");
@mysql_select_db("database");
$url = "http://www.bungie.net/Stats/Reach/default.aspx?player=";
$gamertag = "l RaH 开发者_开发技巧l";
print "<a href=\"".$url.rawurlencode($gamertag)."\">".$gamertag."</a>";
?>
You'll need to select the data from the database, and loop through each result to print the link. This should get you on the right track (you'll need to ensure that the database creditials, name, and table match your local settings).
<?php
mysql_connect('localhost', '', '') or die('Error connecting to MySQL');
mysql_select_db('database');
$url = 'http://www.bungie.net/Stats/Reach/default.aspx?player=';
$query = 'SELECT * FROM tablename';
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
$gamertag = $row['gamertag'];
echo "<a href=\"{$url}{$gamertag}\">{$gamertag}</a><br />";
}
?>
I would highly recommend reading a tutorial on php/mysql so you can understand how they work together. One such tutorial can be found here: http://www.tizag.com/mysqlTutorial/index.php
精彩评论