| | |
HEX colours from mySQL to PHP (in colour)
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Nov 2008
Posts: 18
Reputation:
Solved Threads: 0
Heyy, need some help here.
ok, I've got my script here right.
and it comes out with my tables okay?
bieing:
+----+--------+-------------------------+
| 76 | .enjo. | $i$0f0N$000R$ff0G |
+----+--------+-------------------------+
---- table goes on -----
and this '$i' thing is like trackmania font coosing
so $i$0f0N$000R$ff0G would turn out to be NRG (green N, Black R, Yellow G)
note that thier are tonnes of combonations i dont want to write each on out. so how would i get to remove the $ format codes and replace them with things that work in html/php?
so instead of '$F00MAXICUBE' i want MAXICUBE
colour table: http://tutorials.tm-creative.org/gen...ours/index.php
ok, I've got my script here right.
PHP Syntax (Toggle Plain Text)
<html> <head><title>Display Records</title> <style type="text/css"> td {font-family: tahoma, arial, verdana; font-size: 10pt } </style> </head> <body> <?php $db="aseco121"; $link = mysql_connect('127.0.0.1: 3306', 'root', '******'); if (! $link) die(mysql_error()); mysql_select_db($db , $link) or die("Couldn't open $db: ".mysql_error()); $result = mysql_query( "SELECT * FROM players ORDER BY Login" ) or die("SELECT Error: ".mysql_error()); $num_rows = mysql_num_rows($result); print "There are $num_rows records.<P>"; print "<table width=200 border=1>\n"; while ($get_info = mysql_fetch_row($result)){ print "<tr>\n"; foreach ($get_info as $field) print "\t<td>$field</td>\n"; print "</tr>\n"; } print "</table>\n"; mysql_close($link); ?> <br> </body> </html>
and it comes out with my tables okay?
bieing:
+----+--------+-------------------------+
| 76 | .enjo. | $i$0f0N$000R$ff0G |
+----+--------+-------------------------+
---- table goes on -----
and this '$i' thing is like trackmania font coosing
so $i$0f0N$000R$ff0G would turn out to be NRG (green N, Black R, Yellow G)
note that thier are tonnes of combonations i dont want to write each on out. so how would i get to remove the $ format codes and replace them with things that work in html/php?
so instead of '$F00MAXICUBE' i want MAXICUBE
colour table: http://tutorials.tm-creative.org/gen...ours/index.php
Hi Maxicube - that's some interesting code on trackmania. Haven't seen that type of encoding before.
Can you give more details about how this is going to be used?
For the DB example:
The only thing I can think of is chopping up the string into bits using explode on the '$' character. You know your last chunk is the yellow, penultimate is black and the previous one is yellow. Any bits left over can be compared with a simple array to get the right format (e.g. $i%s -> <em>%s</em>).
If Just colours:
Each example uses the $ + 3 hexadecimal chars. You can use the FONT tag and add a 'color' attribute - but this is bad. A span tag with the 'color' attribute would be more acceptable, although a 'class' attribute linked to a CSS file would be really good. How you'd do the latter I'm not sure as each color would probably require its own class name - bit awkward.
So:
Basically you need to double each hex character and relpace the $ with a #, surround the text part with span tags and insert a color attribute.
Personally, I'd write a function something like this (it's a bit dirty - all the substr!):
USAGE:
Don't know if that's any use?
Can you give more details about how this is going to be used?
For the DB example:
The only thing I can think of is chopping up the string into bits using explode on the '$' character. You know your last chunk is the yellow, penultimate is black and the previous one is yellow. Any bits left over can be compared with a simple array to get the right format (e.g. $i%s -> <em>%s</em>).
If Just colours:
Each example uses the $ + 3 hexadecimal chars. You can use the FONT tag and add a 'color' attribute - but this is bad. A span tag with the 'color' attribute would be more acceptable, although a 'class' attribute linked to a CSS file would be really good. How you'd do the latter I'm not sure as each color would probably require its own class name - bit awkward.
So:
$f00MAXICUBE turns to <span color="#ff0000">MAXICUBE</span> Basically you need to double each hex character and relpace the $ with a #, surround the text part with span tags and insert a color attribute.
Personally, I'd write a function something like this (it's a bit dirty - all the substr!):
PHP Syntax (Toggle Plain Text)
function colorize($tmString){ $colorhex = '#' . substr($tmString,1,1) . substr($tmString,1,1) . substr($tmString,2,1) . substr($tmString,2,1) . substr($tmString,3,1) . substr($tmString,3,1); $string = substr($tmString,4); $output = "<span color=\"{$colorhex}\">{$string}</span>"; return $output; }
USAGE:
PHP Syntax (Toggle Plain Text)
$txt = "$f00MAXICUBE"; echo "I went to a bar and saw " . colorize($txt) . " drinking a soda...";
Don't know if that's any use?
•
•
Join Date: Nov 2008
Posts: 18
Reputation:
Solved Threads: 0
umm, ill give u my table here:
http://phxscape.servegame.com/testin...ay_records.php
and this is how its used:
http://www.tm-forum.com/viewtopic.php?t=1767
thanks for replying, umm, seeing im not realy uptoscratch with javascript, how would i do that? *sigh*
example looks nice
http://phxscape.servegame.com/testin...ay_records.php
and this is how its used:
http://www.tm-forum.com/viewtopic.php?t=1767
thanks for replying, umm, seeing im not realy uptoscratch with javascript, how would i do that? *sigh*
example looks nice
Last edited by maxicube; Jan 30th, 2009 at 3:29 am.
This is good stuff!
You'd have to check for these first, then apply the colorize() function.
I don't know how you'd do shadowed, but most of the others can be set with CSS classes or inline html tags. You could change all of the above to span classes, e.g.
With your CSS:
You'd have to check for these first, then apply the colorize() function.
PHP Syntax (Toggle Plain Text)
$i: italic equivalent to <em></em> $s: shadowed ?? $w: wide CSS class letter spacing? $n: narrow as above $m: normal normal what? $g: default color can be set via CSS $o: bold <strong></strong> $z: reset all this could be tricky $t: Changes the text to capitals CSS class Capitalize $$: Writes a dollarsign
I don't know how you'd do shadowed, but most of the others can be set with CSS classes or inline html tags. You could change all of the above to span classes, e.g.
<span class = "i o w">TEXT</span> for$i$o$wTEXT .With your CSS:
PHP Syntax (Toggle Plain Text)
i{ font-style:italic; } o{ font-weight:bold; } w{ letter-spacing:2em; }
![]() |
Other Threads in the PHP Forum
- Previous Thread: Delete row from database
- Next Thread: Warning: session_start()
| Thread Tools | Search this Thread |
advanced apache api array beginner binary broken cakephp checkbox class cms code cookies cron curl database date datepart display dropdownlist dynamic echo email eregi error execution file files folder form forms function functions google head href htaccess html if...loop image include includingmysecondfileinthechain insert ip javascript job joomla jquery key library limit link login mail menu mlm multiple mysql oop password paypal pdf pdfdownload php phpvotingscript problem query radio random recursion remote screen script search server sessions smarty sms soap sorting source space sql startup stored syntax system table traffic tutorial update upload url validator variable video web xml youtube zend





