开发者

Hyperlink from database for all gamertags?

开发者 https://www.devze.com 2023-02-09 08:19 出处:网络
I would like to be able to connect to a database with this table... +----+----------+-----------+ id | gamertag | timestamp |

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号