I am a serious newbie (like less than two weeks & never programmed before),
so I hope my code doesn't suck too bad & this isn't a really bad question...
but here goes...

I would like to modify this query so that it doesn't return the username,
realname, and office results each time. The way the query is now, I see the
username, realname & office results duplicated for each 'alias' result that
is in the data. Instead, I'd like to see the username, realname & office
only once & a list of the associated 'alias' (es) underneath it. If anyone
can help w/ some "semi-real" code, that would be great.  Since I'm new, it
really helps to have code that actually reflects my field names so that I
can learn from it.  I appreciate any help you can provide.  Thanks in
advance!  ~Andrea
____________________________________

$query = "select users.username, users.realname, users.office,
users.location, users.office_phone, users.alt_phone, users.password,
alias.alias from users, alias
where users.username like '%".$searchterm."%'
and users.username = alias.username";

$result = mysql_query($query);

$num_results = mysql_num_rows($result);

echo "<p>Number of Users found: ".$num_results."</p>";

for ($i=0; $i <$num_results; $i++){
$row = mysql_fetch_array($result);
echo "<p><strong>".($i+1).". Username: ";
echo htmlspecialchars( stripslashes($row["username"]));
echo "<br>Real Name: ";
echo htmlspecialchars( stripslashes($row["realname"]));
echo "<br>Office: ";
echo htmlspecialchars( stripslashes($row["office"]));
echo "<br>Alias: ";
echo htmlspecialchars( stripslashes($row["alias"]));




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to