回显表和html代码

时间:2016-02-02 14:56:34

标签: php html css mysqli

Soo我试图在表格中获取mysql数据,但它给我的错误

function content_temp()
{
    if(isset($_GET['action']))
    {
        if($_GET['action'] == 'bans')
        {
          echo " <table class='MYTABLE'>
          <div class="positiontable">
          <tr CLASS='MYTABLE'>
                    <th CLASS='MYTABLE' height=40 width=80>User</th>
                    <th CLASS='MYTABLE' height=40 width=80>Time</th>
                    <th CLASS='MYTABLE' height=40 width=80>IP</th>
                    <th CLASS='MYTABLE' height=40 width=180>Reason</th>
                    <th CLASS='MYTABLE' height=40 width=80>Admin</th>
                  </tr>
                  </div>
                  </table> ";

        echo " <tr CLASS='MYTABLE'>
            <td CLASS='MYTABLE' height=40 width=80>$name</td>
            <td CLASS='MYTABLE' height=40 width=80>$time</td>
            <td CLASS='MYTABLE' height=40 width=80>$ip</td>
            <td CLASS='MYTABLE' height=40 width=180>$reason</td>
            <td CLASS='MYTABLE' height=40 width=80>$admin</td>
          </tr>";
        }
    }
}

( ! ) Parse error: syntax error, unexpected 'positiontable' (T_STRING), expecting ',' or ';' in C:\wamp\www\ucp\welcome.php on line 88

这是css

CAPTION.MYTABLE
  {
     background-color:#33b061;
     color:33b061;
     border-width:1px;
  }

  TABLE.MYTABLE
  { 
     font-family:calibri;
     font-size:12pt;
     color:#000;
     background-color:#000000;
     width:650px;
     border-color:black;
     border-width:0.4px;
     opacity: 0.6;  }

  TH.MYTABLE
  {
     font-size:12pt;
     color:white;
     background-color:#33b061;  }


  TR.MYTABLE
  {  }

  TD.MYTABLE
  {  
     font-size:12pt;
     background-color:#FFFFFF
     color:white;
     text-align:center;  }
.positiontable
{
    padding: 180px;
    position: fixed;
}

并且有任何方式如果它工作,它只显示idk 10-15字段,而不是它可滚动,是的,表是在mainarea下,我不能选择,复制或粘贴

echo '
    <div id="wrapper">
        <div id="toolbar" align="center">
            <div style="display: inline-block;">
                ',toolbar_temp(),'
            </div>
            <div id="upperimage">
        <div id="mainarea">' ,content_temp(), '</div>   
        </div>
    </div>';
?>

#mainarea {
    background-color: #1a1a1a;
    padding: 800px 100px 0px;
    border-top: 1px solid #000;
    border-left: 1px solid #000;
    border-right: 1px solid #000;
    border-bottom: 1px solid #000;
    margin-top: 100px;
    box-shadow: 0px 0px 14px 4px rgba(0,0,0,0.15);
    opacity: 0.6;
    width: 700px;
    filter: alpha(opacity=60); /* For IE8 and earlier */
}

2 个答案:

答案 0 :(得分:2)

<div class="positiontable">中的function content_temp()文字包含必须转义或替换的引号(因为您使用引号来指定回音)。

例如<div class=\"positiontable\"><div class='positiontable'>

答案 1 :(得分:1)

你在div类中使用双引号创建问题...所以你需要像这样使用你的类......

<div class="positiontable"> or <div class='positiontable'>.  

试试这个..

function content_temp()
{
    if(isset($_GET['action']))
    {
        if($_GET['action'] == 'bans')
        {
          echo " <table class='MYTABLE'>
          <div class='positiontable'>
          <tr CLASS='MYTABLE'>
                    <th CLASS='MYTABLE' height=40 width=80>User</th>
                    <th CLASS='MYTABLE' height=40 width=80>Time</th>
                    <th CLASS='MYTABLE' height=40 width=80>IP</th>
                    <th CLASS='MYTABLE' height=40 width=180>Reason</th>
                    <th CLASS='MYTABLE' height=40 width=80>Admin</th>
                  </tr>
                  </div>
                  </table> ";

        echo " <tr CLASS='MYTABLE'>
            <td CLASS='MYTABLE' height=40 width=80>$name</td>
            <td CLASS='MYTABLE' height=40 width=80>$time</td>
            <td CLASS='MYTABLE' height=40 width=80>$ip</td>
            <td CLASS='MYTABLE' height=40 width=180>$reason</td>
            <td CLASS='MYTABLE' height=40 width=80>$admin</td>
          </tr>";
        }
    }
}