Results 1 to 6 of 6

Thread: How to output colorful data to php page from mysql ?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    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.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: How to output colorful data to php page from mysql ?

    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    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.

  4. #4
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    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.

    BOFH Now, BOFH Past, Information on duplicates

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

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    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>");
      
    ?>

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: How to output colorful data to php page from mysql ?

    You shouldn't use echo to output HTML:

    http://www.vbforums.com/showpost.php...49&postcount=7
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width