Question regarding PHP and mySQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Me@lost_pls_help

    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 phenixthebird@h otmail.com I would be
    greatful.

    ( this is how i retrive my data, should this be changed?)
    <?
    $result = mysql_query("se lect * 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_arr ay($result)) {
    echo"<tr><td class='spacing' ><font face=verdana size=1><b>$row[navn]</b> :
    $row[msg]</td></tr>\n";
    }
    ?>


  • Tom Thackrey

    #2
    Re: Question regarding PHP and mySQL


    On 27-Jul-2003, "Me@lost_pls_he lp" <phenixthebird_ removethis@hotm ail.com>
    wrote:
    [color=blue]
    > 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("se lect * from tagwall order by id desc");
    > //Gets all data from table "tagwall" and sorts by ID, desc. ..desc can be
    > replaced with asc.[/color]
    $ctr = 0;[color=blue]
    > while($row = mysql_fetch_arr ay($result)) {[/color]
    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++;[color=blue]
    > }
    > ?>[/color]



    --
    Tom Thackrey

    Comment

    Working...