国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Associate variable ID with profile page
P粉022285768
P粉022285768 2023-09-10 10:56:31
0
1
893

I have a page that displays some information from the database. I want to add a link to each row (say the name as a link) that I can click to jump to a page that displays the rest of the information for that row (say a profile page). I thought about creating a link that passes the id to the profile page so the profile page can get the information.

I'm sure this is simple, but I just don't get it. How can I display a link in each row that only sends the id number of that row? Because I don't want to go to each row and create a special link.

Here is the code I have:

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// 創(chuàng)建連接
$conn = new mysqli($servername, $username, $password, $dbname);

// 檢查連接
if ($conn->connect_error) {
  die("連接失敗: " . $conn->connect_error);
}


$sql = "SELECT id, FirstName, LastName, Phone, Email FROM Contacts";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
  // 輸出每一行的數(shù)據
  while($row = $result->fetch_assoc()) {
    echo "id: " . $row["id"]. " - Name: " . $row["FirstName"]. " " . $row["LastName"]. " " . $row["Phone"]. " " . $row["Email"]. "
"; } } else { echo "0 結果"; } $conn->close(); ?>```

P粉022285768
P粉022285768

reply all(1)
P粉998100648

Based on your example, you can do this:

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// 創(chuàng)建連接
$conn = new mysqli($servername, $username, $password, $dbname);

// 檢查連接
if ($conn->connect_error) {
    die("連接失敗: " . $conn->connect_error);
}


$sql = "SELECT id, FirstName, LastName, Phone, Email FROM Contacts";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // 輸出每行數(shù)據
    while ($row = $result->fetch_assoc()) {
        echo "id: " . $row["id"] . " - Name: <a href='profile.php/?id=" . $row["id"] . "> " . $row["FirstName"] . "</a> " . $row["LastName"] . " " . $row["Phone"] . " " . $row["Email"] . " <br/>";
    }
} else {
    echo "0 結果";
}

$conn->close();
?>

The profile.php page will use isset to check whether the id is set, and query the data based on id, similar to this: PHP & MYSQL: Select from where id= $id

Not tested, please make sure any user-generated variables are filtered.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template