Professional Web Applications Themes

Question regarding PHP and mySQL - PHP Development

Hi there I guess I am what you would call a newbie to php and mySQL... Ive just created my first guestbook "tagwall" in php using a mysql database to store the messages. So far so good, it works fine and im pleased. Now its time for som cosmetic changes and this is where i need your help. I have no idea how im supposed to do this, I want every other post to have a different background color. For example: Post nr.1 has bg-color: #000000 Post nr.2 has bg-color: #FFFFFF Post nr.3 has bg-color: #000000 Post nr.4 has bg-color: ...

  1. #1

    Default Question regarding PHP and mySQL

    Hi there
    I guess I am what you would call a newbie to php and mySQL... Ive just
    created my first guestbook "tagwall" in php using a mysql database to store
    the messages. So far so good, it works fine and im pleased. Now its time for
    som cosmetic changes and this is where i need your help. I have no idea how
    im supposed to do this, I want every other post to have a different
    background color.
    For example:
    Post nr.1 has bg-color: #000000
    Post nr.2 has bg-color: #FFFFFF
    Post nr.3 has bg-color: #000000
    Post nr.4 has bg-color: #FFFFFF
    and so on......

    Can this be done with a php-script or am I to do this when im fetching my
    data from the database?
    Any suggestions / pseudo-code / hints / complete solutions :-D are welcome
    and greatly appriciated.
    If you would be so kind as to reply to [email]phenixthebirdhotmail.com[/email] I would be
    greatful.

    ( this is how i retrive my data, should this be changed?)
    <?
    $result = mysql_query("select * from tagwall order by id desc");
    //Gets all data from table "tagwall" and sorts by ID, desc. ..desc can be
    replaced with asc.
    while($row = mysql_fetch_array($result)) {
    echo"<tr><td class='spacing'><font face=verdana size=1><b>$row[navn]</b> :
    $row[msg]</td></tr>\n";
    }
    ?>


    Me@lost_pls_help Guest

  2. #2

    Default Re: Question regarding PHP and mySQL


    On 27-Jul-2003, "Melost_pls_help" <phenixthebird_removethishotmail.com>
    wrote:
    > I guess I am what you would call a newbie to php and mySQL... Ive just
    > created my first guestbook "tagwall" in php using a mysql database to
    > store
    > the messages. So far so good, it works fine and im pleased. Now its time
    > for
    > som cosmetic changes and this is where i need your help. I have no idea
    > how
    > im supposed to do this, I want every other post to have a different
    > background color.
    > For example:
    > Post nr.1 has bg-color: #000000
    > Post nr.2 has bg-color: #FFFFFF
    > Post nr.3 has bg-color: #000000
    > Post nr.4 has bg-color: #FFFFFF
    > and so on......
    >
    > Can this be done with a php-script or am I to do this when im fetching my
    > data from the database?
    > (snip)
    > ( this is how i retrive my data, should this be changed?)
    > <?
    > $result = mysql_query("select * from tagwall order by id desc");
    > //Gets all data from table "tagwall" and sorts by ID, desc. ..desc can be
    > replaced with asc.
    $ctr = 0;
    > while($row = mysql_fetch_array($result)) {
    echo"<tr><td class='spacing'><font face=verdana size=1
    color=",($ctr%2)?"black":" blue","><b>$row[navn]</b> :
    $row[msg]</td></tr>\n";
    $ctr++;
    > }
    > ?>


    --
    Tom Thackrey
    [url]www.creative-light.com[/url]
    Tom Thackrey Guest

Similar Threads

  1. php or mysql question
    By Jason Cooke in forum PHP Development
    Replies: 2
    Last Post: January 20th, 07:25 PM
  2. dbi::mysql question
    By rob merritt in forum PERL Beginners
    Replies: 0
    Last Post: January 2nd, 06:53 PM
  3. More of a mysql question
    By hokieghal99 in forum PHP Development
    Replies: 1
    Last Post: October 27th, 02:43 PM
  4. PHP + MYSQL Question!
    By R.Lange in forum PHP Development
    Replies: 2
    Last Post: July 20th, 01:03 PM
  5. A MySQL question
    By Zavaboy in forum PHP Development
    Replies: 5
    Last Post: July 14th, 11:26 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139