shadrxninga Posted March 22, 2011 Share Posted March 22, 2011 At the moment with this code I have a border around each name but I wanted to get a border around all of the names and if the username is equal to shadrxninga make it red. // Conect to the Mysql Server $connect = mysql_connect("localhost","user","pass") or die(mysql_error()); //connect to the database mysql_select_db("db"); //query the database $query = mysql_query("SELECT * FROM users_online WHERE online = 1"); // fetch the results / convert into an array WHILE($rows = mysql_fetch_array($query)): $users = $rows['name']; if ( $users == shadrxninga ) { echo "<p><div style='width:200px;height:20px;border:2px outset red'><center>$users</center></div></p>"; } else { echo "<div style='width:200px;height:px;border:2px outset blue'><center>$users</center></div>"; } endwhile; ?> But I have no idea how? I have tried a few things but the have all ended in errors If you want to see what it looks like go to http://www.scswc.com Thanks Quote Link to comment https://forums.phpfreaks.com/topic/231362-php-and-css/ Share on other sites More sharing options...
kenrbnsn Posted March 22, 2011 Share Posted March 22, 2011 Your example looks fine other than you should quote the string in the "if" statement: <?php if ( $users == 'shadrxninga' ) { ?> Also, your link seems to do what you want it to do. What's the problem? Ken Quote Link to comment https://forums.phpfreaks.com/topic/231362-php-and-css/#findComment-1190726 Share on other sites More sharing options...
shadrxninga Posted March 22, 2011 Author Share Posted March 22, 2011 I wanted to make it so both usernames were in one border but 'shadrxninga' was red Quote Link to comment https://forums.phpfreaks.com/topic/231362-php-and-css/#findComment-1190728 Share on other sites More sharing options...
kenrbnsn Posted March 22, 2011 Share Posted March 22, 2011 So you want one box around all the names and make the name red if the name is 'shadrxninga'? <?php echo '<div style="border: 2px outset blue">'; WHILE($rows = mysql_fetch_array($query)) { $users = $rows['name']; $color = ($users == 'shadrxninga')?'red':'black'; echo "<p style='color:$color;text-align:center'>$users</p>"; } echo '</div>'; ?> Note: untested. Ken Quote Link to comment https://forums.phpfreaks.com/topic/231362-php-and-css/#findComment-1190732 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.