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
);
Re: How to output colorful data to php page from mysql ?
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.
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.
Re: How to output colorful data to php page from mysql ?
Quote:
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>");
?>
Re: How to output colorful data to php page from mysql ?