mxyi Posted July 16, 2010 Share Posted July 16, 2010 hey guys i got this code for a player usercard but i wanted to add 'Online :' and after : saying yes or no in them colors how can i add it so it says theyre status? here is the code.. :) <?php //Coded By Eternal //www.deadlyghetto.net //Leave this please include "config.php"; global $_CONFIG; define("MONO_ON", 1); require "class/class_db_mysql.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; if(isset($_GET['id']) AND ctype_digit($_GET['id'])) { $id = mysql_real_escape_string(trim($_GET['id'])); } else {echo" Invalid Action";} if($id) { $query = sprintf("select level, username,money,crystals from users where userid = %u",$id); $result = mysql_query($query); $data = mysql_fetch_array($result); $info ="{$data['username']} \nLevel: {$data['level']} \nCash: \$".number_format($data['money'])."\nCrystals: ".number_format($data['crystals']).""; // Create a 300x100 image $im = imagecreatetruecolor(200, 100); $image = imagecreatefrompng('americawars.png'); // Get a background for jpg it is imagecreatefromjpg() imagealphablending($image, true); // setting alpha blending on ~~~ remove if not using png imagesavealpha($image, true); // save alphablending setting (important) ~~~ remove if not using png $color = imagecolorallocate($image, 0x250, 0x250, 0x250); // Path to our ttf font file $font_file = 'Babelfish.ttf'; imagefttext($image, 14, 0, 15, 85, $color, $font_file, $info); // I S R L T C F TX /*************************\ I= Background image S= Font Size R= Right Border L= Left Border T= Top Border C Font Color* Colour F File to load eg.. arial.ttf TX Text Info */ // Output image to the browser header('Content-Type: image/png'); imagepng($image); imagedestroy($image); } else{echo" die";} ?> hope u can help me add the online status because i only know how to add things that are in the mysql database :P thanks! Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted July 16, 2010 Share Posted July 16, 2010 It is in the mysql database. In that code after line 28 add if($data['laston'] >= time()-15*60) { $on="Online"; } else { $on="Offline"; } Then add to your $info line where you want the status to be displayed. $info ="{$data['username']} \nLevel: {$data['level']} \nCash: \$".number_format($data['money'])."\nCrystals: ".number_format($data['crystals'])." \nStatus: {$on}"; In order to get it to display in different colours you will need to play with the imagecolorallocate Quote Link to comment Share on other sites More sharing options...
mxyi Posted July 16, 2010 Author Share Posted July 16, 2010 ahh thanks i had a code abit like if($data['laston'] >= time()-15*60) { $on="Online"; } else { $on="Offline"; } but it wasnt working for some reason but that should work ill try it out now many thanks :) Quote Link to comment Share on other sites More sharing options...
mxyi Posted July 16, 2010 Author Share Posted July 16, 2010 all i get is the broken image thingy, how do i fix this? fixed : you had to add the laston so it imports the data from the database :P Quote Link to comment Share on other sites More sharing options...
r14170 Posted July 25, 2010 Share Posted July 25, 2010 how to add the laston? :D Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted July 25, 2010 Share Posted July 25, 2010 $query = sprintf("select level, username,money,crystals from users where userid = %u",$id); change to $query = sprintf("select level, laston, username,money,crystals from users where userid = %u",$id); 8o Quote Link to comment Share on other sites More sharing options...
r14170 Posted July 25, 2010 Share Posted July 25, 2010 im starting to learn something :D Quote Link to comment 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.