0

I have hit a bump on my road and quite figure out how to get this working the way I want. I hope some of you can give me a helping hand with this!

Currently I have a table that displays some information from my database on my website and that is working great, however I can't figure out how I make a link within my table. I need to use an external website that I can link to and at the same time use one of my $row in the link. Here is my code:

<!DOCTYPE html>
<html>
<head>
    <title>Store Topliste</title>
</head>
<body>
<h4>Denne side viser dig en liste over dem der har flest Credits i Store</h4></br></br>
<table>
    <tr>
        <th>Rank</th>
        <th>Navn</th>
        <th>Credits</th>
        <th>Steam ID</th>
        <th>Sidst Online</th>
    </tr>
    <?php
    $conn = mysqli_connect("HOST", "DATABASE", "PASSWORD", "USER");
    if ($conn-> connect_error) {
        die("Connection failed:". $conn-> connect_error);
    }

    $sql = "SELECT name, authid, credits, date_of_last_join from store_players ORDER BY credits DESC LIMIT 250";
    $result = $conn-> query($sql);

    if ($result-> num_rows > 0) {
            $rank = 1;
        while ($row = $result-> fetch_assoc()) {
            echo "<tr><td>". $rank ."</td><td>" . $row["name"] . "</td><td>". $row["credits"] . "</td><td>" . "STEAM_1:", $row["authid"] . "</td><td>" . strftime("%d.%m.%Y %H:%M:%S", $row["date_of_last_join"]) . "</td></tr>";
            $rank++;
        }
        echo "</table>";
    }
    else {
        echo "0 result";
    }

    $conn-> close();
    ?>
</table>
<br>
<p>- Dette system er udviklet af <a href="https://steamcommunity.com/id/LasBoi">LasBoi</a> med ♥. </p>
</body>
</html>

So here is a picture of what it looks like: Website Example

What I want is that the STEAM_1:1:61281672 (" . "STEAM_1:", $row["authid"] . ") links to this address - "https://steamidfinder.com/lookup/STEAM_1:" and that the rest of the website link will be filled out by $row["authid"] so it will be a complete link to the profile on that site. And still maintain the same text structure (STEAM_1:1:61281672) that is already on my website.

1
  • 1
    in HTML, links are created using <a elements e.g. <a href="http://www.example.com">Click here</a>. So you just need to make your PHP output that within one of your table cells (and obviously substitute the URL and the text for whatever you want it to say). Commented Feb 27, 2020 at 12:51

1 Answer 1

4

You would just create the link as part of your HTML output:

<td><a href=\"https://steamidfinder.com/lookup/STEAM_1:?steam_id=\"" . $row["authid"] . "\">STEAM_1:" . $row["authid"] . "</a></td>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.