mysql error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jamal
Forum Commoner
Posts: 57
Joined: Sat Oct 26, 2002 7:53 pm
Location: London

mysql error

Post by jamal »

Hi Guys,
Can anyone please help me on this issue.
The below code did not print all the values in the table.
Instead it printed only the ID with the values.
Please if you know how to solve the problem.
I would like to print the values in real_name,username,email,respectively
but not the password.
Thanks


Code: Select all

<?php
echo "<html><head><title>User Information</title></head><body
bgcolor=#ffffff>";

$connection = mysql_connect("localhost","user","pass")
or die ("Unable to connect to MySQL server.");
$db = mysql_select_db("secretDB", $connection) or die ("Unable to select
database.");
$sql = "SELECT id, real_name, username, email
		FROM users
		ORDER BY id ASC";
$sql_result = mysql_query($sql,$connection) or die ("Couldn't execute SQL
query");
echo "<center><b><u>List of users</u></b><br><Br>";
echo "<table bgcolor=#000000><Tr><td bgcolor=#000000><table cellpadding=4
cellspacing=0 bgcolor=#ffffff>"; echo "<Tr><th>ID</th><th>Full
Name</th><th>Username</th><th>E-mail</th></tr>"; while ($row =
mysql_fetch_array($sql_result)) { $id = $row["id"];
$real_name = $row["real_name"];
$username = $row["username"];
$email = $row["email"];
echo
"<tr><td>$id</td><td>$real_name</td><td>$username</td><td>
<a href="mailto:$email">$email</a></td></tr>"; }
echo "</table></td></tr></table>";
echo "</center>";
mysql_free_result($sql_result);
mysql_close($connection);
echo "</body></html>";
?>
User avatar
Elmseeker
Forum Contributor
Posts: 132
Joined: Sun Dec 22, 2002 5:48 am
Location: Worcester, MA

Post by Elmseeker »

Change:

Code: Select all

<?php
echo 
"<tr><td>$id</td><td>$real_name</td><td>$username</td><td> 
<a href="mailto:$email">$email</a></td></tr>";
?>
To:

Code: Select all

<?php
echo 
"<tr><td>$id</td><td>".$real_name."</td><td>".$username."</td><td><a href="mailto:".$email."">".$email."</a></td></tr>";
?>
Post Reply