Web Hosting Talk







View Full Version : something easy yet...


brcolow
04-24-2003, 10:22 PM
Hi all :) I know some people here don't like me, well...sorry :(

Anyways, I have a code that displays the users online by selecting from a table like this:

$query = "SELECT DISTINCT * from battle_sessions";
$mysql_result = mysql_query($query);
while($row = mysql_fetch_array($mysql_result, MYSQL_ASSOC))
{
$link_challenge = append_sid("battle.$phpEx?mode=challenge&id=$row[user_id]");
$query2 = "SELECT * from phpbb_users where user_id = '$row[user_id]'";
$mysql_result2 = mysql_query($query2);

$row2 = mysql_fetch_array($mysql_result2, MYSQL_ASSOC);
print '<a href="' . $link_challenge . '">' . $row['username']. '</a><br>';

}

That works fine BUT now if and when it gets to their username I dont want it to make it a link, but it does...
Thanks :D

MarkIL
04-25-2003, 01:50 AM
Uhm, shouldn't the username link refer to $row2['username'] and not $row['username']?

ChickenSteak
04-25-2003, 02:21 AM
print "<a href=\"$link_challenge\">{$row2['username']}</a><br>";

try that.

Rich2k
04-25-2003, 04:56 AM
Although wouldn't it be easier to do a sql table join?

brcolow
04-25-2003, 07:15 PM
Uhh, this code already works, reread my question....

brcolow
04-27-2003, 12:54 AM
bump

kickmybutt
04-27-2003, 01:07 AM
HINT!! "a href" creates a hyperlink;) Now, look at the script again.

brcolow
04-27-2003, 02:29 AM
People listen: The script works FINE 100% but I want to make an add on to it. When the user is on the page, it DOESNT display their username but everyone elses.....

digitok
04-27-2003, 02:32 AM
Okay whats your point? He has a href.

brcolow
04-27-2003, 02:33 AM
Lol great....advice.....
Anyway what I mean is I want it to display theirs but not make it a link, i.e. they cant challenge themselves.

digitok
04-27-2003, 02:38 AM
if ($row['username'] != <their username>) { // code without link }
else { // code with link }