dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: beginner format question

  1. #1
    Join Date
    Jan 2009
    Posts
    16

    beginner format question

    Hi,
    how can I change the format of a cell with php?
    In plain English something like;

    If ($i==10)
    {
    replace <td> with <td class="MyClass">
    }

    thanks for any help.

  2. #2
    Join Date
    Nov 2006
    Location
    Springfield, MO
    Posts
    1,541
    Why not:

    PHP Code:
    If ($i==10)
    {
    echo 
    "<td class='MyClass'></td>" ;
    }else{
    echo 
    "<td>blah</td>";

    Ryan Butler

    Ryan Butler.org

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    21,433
    I sometimes use this approach:
    PHP Code:
    $class = ($i == 10) ? " class='MyClass'" "";
    echo 
    "<td$class>blah</td>\n"
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles