Hey guys, I have a php script which allows the user to view the list of users on the website:
<?php
$con = mysql_connect("localhost","User","Pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$query="SELECT * FROM users ORDER BY `Username`"; // query string stored in a variable
$rt=mysql_query($query); // query executed
echo mysql_error(); // if any error is there that will be printed to the screen
while($nt=mysql_fetch_array($rt)){
echo "<a href='profile.php?id=".$row['ID']."'>$nt[Username]" . "</a><br />" ; // name class and mark will be printed with one line break at the end
}
?>
That works, but when you click the username of someone, it doesn't take you to their profile page.
The script for that is:
$result = mysql_query("SELECT * FROM users WHERE `id`='".mysql_escape_string($_GET['id'])."'");
while($row = mysql_fetch_array($result))
{
echo "<h1>" . $row['Username'] . "</h1>" . " " . "<p>" . $row['Level_access'] . "</p>";
echo "<br />";
}
This is supposed to get the ID and display the information, but the ID isn't collected. Any one know why?
Any help would be much appreciated
<?php
$con = mysql_connect("localhost","User","Pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$query="SELECT * FROM users ORDER BY `Username`"; // query string stored in a variable
$rt=mysql_query($query); // query executed
echo mysql_error(); // if any error is there that will be printed to the screen
while($nt=mysql_fetch_array($rt)){
echo "<a href='profile.php?id=".$row['ID']."'>$nt[Username]" . "</a><br />" ; // name class and mark will be printed with one line break at the end
}
?>
That works, but when you click the username of someone, it doesn't take you to their profile page.
The script for that is:
$result = mysql_query("SELECT * FROM users WHERE `id`='".mysql_escape_string($_GET['id'])."'");
while($row = mysql_fetch_array($result))
{
echo "<h1>" . $row['Username'] . "</h1>" . " " . "<p>" . $row['Level_access'] . "</p>";
echo "<br />";
}
This is supposed to get the ID and display the information, but the ID isn't collected. Any one know why?
Any help would be much appreciated