Jump to content

Php and Css


shadrxninga

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.