PHP,如何制作:domain.com/profile.php?user=admin [关闭]

I'm making an profile page in PHP,

How to make an url like domain.com/profile.php?user=admin works in PHP? (this will show the profile of the user "admin")

Thnx!

Assuming you have a database and a db connection and a selected db.

<?php
// Get your variable (admin)
$user = mysql_real_escape_string($_GET["user"]);

// now query the db
$sql = "SELECT * FROM your_user_database WHERE user = '$user'";
$result = mysql_query($sql);
$datarow = mysql_fetch_row($result);
?>

Now use the datarow in your html.

<div>
    <?php echo $datarow[0] ?> <?php echo $datarow[1] ?> etc...
</div>

Good luck