#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Posts
    10
    Rep Power
    0

    Unhappy Formatting Output in Table using Printf and CSS


    As you may guess, I am new to PHP and am experiencing some frustration with attempting to format data in a table. Here is my statement for the first row of the table, which contains the statement :

    printf ('<td width=\"192\" height=\"14\" valign=\"top\" class=\"Header1\"><a href="%s">%s</a></td>', "$PHP_SELF?sort=dept_sort", "Department");

    Problem is, the reference to the Class does not work. I get no errors, but the font does not get formatted as Header1. I have tried various iterations of this using <Span> outside of the <Td> tag to set the font, etc., but nothing seems to work. The font does not get set to the style in Header1. I have spent hours on this - can someone help me? Is there a better way to do this?

    Thanks!

    Marcie
  2. #2
  3. Newbie :P
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Jan 2001
    Location
    In the PHP Engine :-)
    Posts
    2,880
    Rep Power
    21
    Hi Marcie,

    I have never really used CSS with PHP but I have a suggestion you might want to try.

    Rather than print it all in PHP try exiting PHP into HTML and then re-entering PHP, like so...

    PHP Code:
    <?
    // Lots of other loverly PHP code here
    ?>
    <td width="192" height="14" valign="top" class="Header1">
    <?
    printf 
    ('<a href="%s">%s</a></td>'"$PHP_SELF sort=dept_sort""Department"); 
    ?>
    Just an idea
    ---------------------
    -- SilkySmooth --
    ---------------------
    Proxy
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Posts
    10
    Rep Power
    0

    It Works!


    Thanks Ade,

    Your solution worked just great! I'm finding that there are many different ways to do things in PHP!

    Marcie
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2001
    Location
    In a multi-cultural mess.
    Posts
    569
    Rep Power
    14
    marcie,

    You might as well apply SilkySmooth's idea to both lines
    of code. Drop the printf.
    PHP Code:
    ?>
    <td width="192" height="14" valign="top" class="Header1">
    <?
    printf_
    ('<a href="%s">%s</a></td>',_"$PHP_SELF_sort=dept_sort",_"Department");
    ?>
    as in
    PHP Code:
    ?>
    <td width="192" height="14" valign="top" class="Header1">
    <a href="<?=$PHP_SELF?>?sort=dept_sort">Department</a></td>
    ?>
    Hope this helps,
    Robert
    Robert
    ---
    If it's hard, it's probably wrong.

IMN logo majestic logo threadwatch logo seochat tools logo