|
-
Jul 4th, 2006, 01:58 AM
#1
Thread Starter
Frenzied Member
How to output colorful data to php page from mysql ?
Hi all i got this table in mysql database and i want to output to a php page all the names in database and each name should have the same color as it specifed for that name in database. For example if name cindy has color code 16711935 then her name should should be displaied using that code which represent pink. I be happy if some one show me how i can achive this task using php.Thanks
Code:
create table NameColor
(
ID int auto_increment primary key,
Name varchar(32),
color int
);
Last edited by tony007; Jul 4th, 2006 at 02:04 AM.
-
Jul 4th, 2006, 02:31 AM
#2
Re: How to output colorful data to php page from mysql ?
-
Jul 4th, 2006, 08:57 AM
#3
<?="Moderator"?>
Re: How to output colorful data to php page from mysql ?
People aren't going to write all the code for you, you need to get started yourself and then come back when you run into trouble. If you are looking for someone to do it all for you then there are many sites, like visualAd suggested, where people will do all the work for you at a price.
Last edited by john tindell; Jul 4th, 2006 at 09:05 AM.
-
Jul 4th, 2006, 09:01 AM
#4
Re: How to output colorful data to php page from mysql ?
Two choices:
1) use Css
2) use inline font colors
Probably the second would be better.
HTML:
Code:
<font color='<number here>'>Words</font>
That is the most simplistic - you need to retrieve the number from the db (probably on a query/table loop) and write it to the page.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jul 4th, 2006, 09:54 AM
#5
Thread Starter
Frenzied Member
Re: How to output colorful data to php page from mysql ?
 Originally Posted by Ecniv
Two choices:
1) use Css
2) use inline font colors
Probably the second would be better.
HTML:
Code:
<font color='<number here>'>Words</font>
That is the most simplistic - you need to retrieve the number from the db (probably on a query/table loop) and write it to the page.
Thanks man i tried this and it gives me error. Also i do know what format should wirte so it takes value of color from db!!
i tried this and gives me syntax erro
echo("<tr><td><font color="#FF00FF">$Name</font></td>
furthermore i want to replace #FF00FF with value color from db but i do not know what format should i write it instead of color="????"
PHP Code:
<?
require("util.php");
$sql = new MySQL_class;
$sql->Create("color");
#
# Selecting Multiple Rows
#
echo("<html>");
echo("<head>");
echo("<p><ul><table border=1 cellpadding=4>\n");
echo("<tr><th>Name</th> > <th> color </th> </tr>\n");
$sql->Query("Select Name,color from NameColor");
for ($i = 0; $i < $sql->rows; $i++) {
$sql->Fetch($i);
$Name = $sql->data[0];
$color = $sql->data[1];
echo("<tr><td>$Name</td> <td>$color</td> \n");
#echo("<tr><td><font color="#FF00FF">$Name</font></td> <td>$color</td> \n"); ==> error here
}
echo("</table>\n");
echo("</body>");
echo("</html>");
?>
-
Jul 4th, 2006, 01:58 PM
#6
Re: How to output colorful data to php page from mysql ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|