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
https://forums.phpfreaks.com/topic/231362-php-and-css/
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
https://forums.phpfreaks.com/topic/231362-php-and-css/#findComment-1190732
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.