#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Kapiti, New Zealand
    Posts
    36
    Rep Power
    14

    CSS not applied to include


    I've got a problem with a css class that does not display correctly for one include file.

    PHP Code:
    <span class="smallcart">
    <?php
    if ($action != "edititem") {
    $action="";                
    include (
    'displaysmallcart.php');
    }
    include (
    'randombook.php');
    ?>
    </span>
    The problem is that displaysmallcart.php does not have the formatting described in the smallcart class of the css but randombook.php does. displaysmallcart doesn't have any formatting in it other than table tags.
    Gravity always wins
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jul 2001
    Location
    Oslo
    Posts
    1,516
    Rep Power
    14
    Your problem is certainly not a PHP problem, but rather related to your CSS or the contents of displaysmallcart.php.

    Try being more specific for example by posting the CSS that isn't being applied, and the HTML to which it should be applied.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Kapiti, New Zealand
    Posts
    36
    Rep Power
    14
    CSS:

    .smallcart{
    background-color: transparent;
    font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
    font-size : xx-small;
    text-decoration : none;
    }

    displaysmallcart.php:
    <?php
    mysql_connect ($dbhost, $dbuser, $dbpass) or die("Could not Connect");
    mysql_select_db ("testss");
    $query = "select * from carttable where sessid = '$s'";
    $result = mysql_query ($query) or die ("Could not execute query");
    print '<table>';
    while ($query_data = mysql_fetch_array($result)) {
    echo "<tr><td>",$query_data[product],"</td><td>",$query_data[fabric],"</td><td>",$query_data[size], "</td><td>";
    ?>
    <form method="post" action="edititem.php?s=<?php echo $s?>&action=<?php echo $action?>">
    <input type="hidden" name="itemno" value ="<?php echo $query_data[id]?>"</input>
    <input type="image" border="0" name="submit" src="images/delete.gif"></input>
    </form></td></tr>
    <?php
    }
    print '</table>';
    ?>

    HTML source generated:
    <span class="smallcart">
    <table><tr><td>tights</td><td>Camel</td><td>1 Year</td><td>
    <form method="post" action="edititem.php?action=">
    <input type="hidden" name="itemno" value ="8"</input>
    <input type="image" border="0" name="submit" src="images/delete.gif"></input>
    </form></td></tr>
    </table>Test to see that randombook.php is included (text only file at this stage)</span>

    The table generated by displaysmallcart.php is not formatted with the smallcart class, but with the default format. randombook.php is formatted correctly by smallcart class
    Gravity always wins
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jul 2001
    Location
    Oslo
    Posts
    1,516
    Rep Power
    14
    Ah, I guess you're using IE to display the page. One thing to remember about CSS is that the current implementations are buggy, so when using CSS, always make sure to keep a good buglist under your pillow.

    As for this particular error; IE doesn't apply inheritance correctly for tables, so tables won't inherit the style set for body or any other wrapping element. The simplest workaround is to create a style definition for the table aswell:

    .smallcart table {
    background-color: transparent;
    font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
    font-size : xx-small;
    text-decoration : none;
    }
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Kapiti, New Zealand
    Posts
    36
    Rep Power
    14
    Fantastic!!! Thanks very much. It works perfectly
    Gravity always wins

IMN logo majestic logo threadwatch logo seochat tools logo