TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,970
  • Latest: bynw
Stats
  • Total Posts: 196,047
  • Total Topics: 21,336
  • Online today: 163
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 159
  • Total: 159

Stylesheets

Started by RJL61, May 27, 2007, 06:38:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

RJL61

I've included a top 10 players menu on My site. I uploaded the php file, and wrote a php article with the include statement, then created a new menu to link to the article. It works fine except that the php file has a stylesheet. When I click on the menu for it, it comes up, but causes the whole site to use that stylesheet. I removed the whole <style></style> but I'd like to be able to use it. Any ideas?

Here's the orignal code:

<style type="text/css">
<!--
body,td,th {
    border-Left-Color: #151515;
    border-Bottom-Width: 1px;
    border-Bottom-Style: solid;
    border-Right-Width: 1px;
    border-Top-Style: solid;
    border-Right-Color: #2E2E40;
    border-Top: #151515 1px solid;
    border-Top-Width: 1px;
    border-Bottom-Color: #2E2E40;
    border-Top-Color: #151515;
    border-Width: 1px 1px 0px 1px;
    border-Left: #151515 1px solid;
    border-Right: #2E2E40 1px solid;
    border-Style: solid;
    border-Left-Style: solid;
    border-Right-Style: solid;
    border-Bottom: #2E2E40 1px solid;
    border-Left-Width: 1px;
font-family: Tahoma;
color: #666666;
font-size:12px;
}
body {
background-color: #000000;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
a:link {
color: #cc0000;
text-decoration: none;
}
a:visited {
color: #CC0000;
text-decoration: none;
}
a:hover {
color: #6699ff;
text-decoration: none;
}
a:active {
color: #990000;
text-decoration: none;
}
-->
</style>
<?php

/*
*Ryan Kelley
*ryan(at)staticsoldiers.net
*/

include("config.php");

if(empty(
$dbport))
       
$dbport = 3306;

if(
$dbtype=="mysql")
{
       
$plrData = array();
       
$conn = mysql_connect($dbhost.":".$dbport,$dbuser,$dbpass) or die(mysql_error());
       
mysql_select_db($dbname,$conn) or die(mysql_error());

       
$query = "select plrid,uniqueid,rank,skill from ".$dbtblprefix."plr where allowrank=1 order by skill desc limit 10";
       
$result = mysql_query($query);

       for(
$i=0;$row = mysql_fetch_array($result);$i++)
       {
               for(
$j=0;$j<4;$j++)
               {
                       
$plrData[$i][$j] = $row[$j];
               }
       }

       print(
"<table width=\"100%\" align=\"center\" cellpadding=\"5\"><tr><td colspan=\"8\" style=\"background: #000000 url(images/bar2.jpg) repeat-x\" align=\"center\"><font size=\"+1\" color=\"#cc0000\">Top 10</font></td></tr><tr>
       <td style=\"background: #050505\">Rank</td><td style=\"background: #050505\">Name</td><td style=\"background: #050505\">Kills</td><td style=\"background: #050505\">Deaths</td><td style=\"background: #050505\">K:D</td><td style=\"background: #050505\">K:M</td><td style=\"background: #050505\">Online Time</td><td style=\"background: #050505\">Skill</td></tr>"
);
       for(
$i=0;$plrData[$i][0]!=null;$i++)
       {
               
$query = "select name from ".$dbtblprefix."plr_profile where uniqueid='".$plrData[$i][1]."' limit 1";
               
$ans = mysql_fetch_array(mysql_query($query));
               
$plrData[$i][4] = $ans[0];

               
$query = "select kills,deaths,onlinetime,killsperdeath,killsperminute from ".$dbtblprefix."c_plr_data where plrid=".$plrData[$i][0];
               
$ans = mysql_fetch_array(mysql_query($query));
               
$plrData[$i][5] = $ans[0];
               
$plrData[$i][6] = $ans[1];
               
$plrData[$i][7] = $ans[2];
               
$plrData[$i][8] = $ans[3];
               
$plrData[$i][9] = $ans[4];


               print(
"
               <tr>
                       <td style=\"background: #000000 url(images/bar2.jpg) repeat-x\" align=\"center\">"
.$plrData[$i][2]."</td>
                       <td style=\"background: #000000 url(images/bar2.jpg) repeat-x\"><a href=\"index.php?search="
.$plrData[$i][4]."&submit='go'\" target=\"_parent\">".$plrData[$i][4]."</a></td>
                       <td style=\"background: #000000 url(images/bar2.jpg) repeat-x\">"
.$plrData[$i][5]."</td>
                       <td style=\"background: #000000 url(images/bar2.jpg) repeat-x\">"
.$plrData[$i][6]."</td>
                       <td style=\"background: #000000 url(images/bar2.jpg) repeat-x\">"
.$plrData[$i][8]."</td>
                       <td style=\"background: #000000 url(images/bar2.jpg) repeat-x\">"
.$plrData[$i][9]."</td>
                       <td style=\"background: #000000 url(images/bar2.jpg) repeat-x\">"
.myTime($plrData[$i][7])."</td>
                       <td style=\"background: #000000 url(images/bar2.jpg) repeat-x\">"
.$plrData[$i][3]."</td>
               </tr>"
);
       }
       print(
"<tr><td colspan=\"8\" style=\"background: #000000 url(images/bar2.jpg) repeat-x\" align=\"center\">Powered by Psychostats 3.0.5</td></tr></table>");
}
mysql_close($conn);
function
myTime($time)
{
       if(
$time >= 3600)
       {
               for(
$hour=0;$time>=3600;$hour++)
               {
                       
$time -= 3600;
               }
       }
       else
       {
               
$hour = "0";
       }
       if(
$time >=60 )
       {
               for(
$min=0;$time>=60;$min++)
               {
                       
$time -= 60;
               }
       }
       else
       {
               
$min = "00";
       }
       
$sec = $time;


       return
"$hour:$min:$sec";

}
?>

Nokonium

#1
This if it works (untried), would only work with one theme.

Try to add the styles to the theme style.css, give them their own id's or classes. In the php file link to the theme stylesheet.

[edit]Thinking about it, just giving them their own styles may be worth trying first.

RJL61

Quote from: nokonium on May 27, 2007, 10:08:57 PM
This if it works (untried), would only work with one theme.

Try to add the styles to the theme style.css, give them their own id's or classes. In the php file link to the theme stylesheet.

[edit]Thinking about it, just giving them their own styles may be worth trying first.

Not sure what You mean. How can I accomplish this?

Nokonium

Your styles include 'body, th, td' these are already defined in the theme stylesheet and that is probably why it changes the whole site. You do not need the body tag in a php article. It doesn't look like you have any a link's in what is printed to screen so you don't need those either.

Your three print calls are to display a table, which also has inline styles. You need to simplify this by defining the style in the stylesheet and using the style class in the print sections of the script. You also have a great deal of duplication in your css styles for example the 'border', you only need the 4 shorthand lines for the top, right bottom and left.

For example:

This

body,td,th {
    border-Left-Color: #151515;
    border-Bottom-Width: 1px;
    border-Bottom-Style: solid;
    border-Right-Width: 1px;
    border-Top-Style: solid;
    border-Right-Color: #2E2E40;
    border-Top: #151515 1px solid;
    border-Top-Width: 1px;
    border-Bottom-Color: #2E2E40;
    border-Top-Color: #151515;
    border-Width: 1px 1px 0px 1px;
    border-Left: #151515 1px solid;
    border-Right: #2E2E40 1px solid;
    border-Style: solid;
    border-Left-Style: solid;
    border-Right-Style: solid;
    border-Bottom: #2E2E40 1px solid;
    border-Left-Width: 1px;
font-family: Tahoma;
color: #666666;
font-size:12px;
}
body {
background-color: #000000;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}

print("<table width=\"100%\" align=\"center\" cellpadding=\"5\"><tr><td colspan=\"8\" style=\"background: #000000 url(images/bar2.jpg) repeat-x\" align=\"center\"><font size=\"+1\" color=\"#cc0000\">Top 10</font></td></tr><tr>
        <td style=\"background: #050505\">Rank</td><td style=\"background: #050505\">Name</td><td style=\"background: #050505\">Kills</td><td style=\"background: #050505\">Deaths</td><td style=\"background: #050505\">K:D</td><td style=\"background: #050505\">K:M</td><td style=\"background: #050505\">Online Time</td><td style=\"background: #050505\">Skill</td></tr>");


could then be written as this


.topten
{
color: #666666;
font-family: Tahoma;
font-size:12px;
border-Top: #151515 1px solid;
border-Right: #2E2E40 1px solid;
border-Bottom: #2E2E40 1px solid;
border-Left: #151515 1px solid;
width: 100%;
margin: 0;
background-color: #000000;
padding: 5;
align: centre;
}

.topten td1
{
background: #000000 url(images/bar2.jpg) repeat-x;
color: #666666;
font-size:14px;
}

.topten td2
{
background: #050505;
}





print("<table class=\"topten\">
<tr>
      <td class=\"topten td1\" colspan=\"8\">Top 10</td>
</tr>
<tr>
      <td class=\"topten td2\">Rank</td>
      <td class=\"topten td2\">Name</td>
      <td class=\"topten td2\">Kills</td>
      <td class=\"topten td2\">Deaths</td>
      <td class=\"topten td2\">K:D</td>
      <td class=\"topten td2\">K:M</td>
      <td class=\"topten td2\">Online Time</td>
      <td class=\"topten td2\">Skill</td>
</tr>");
       


You should then add the topten styles to your theme style.css file and remove the styles from the script

RJL61

Thanks very much for the info. I'll try to implement this, and see how it works  ;)

This website is proudly hosted on Crocweb Cloud Website Hosting.