【问题标题】:Change echo table properties更改回波表属性
【发布时间】:2017-11-07 07:38:51
【问题描述】:

我在这里遇到了这种紧急情况;我的朋友已经完成了我这样的代码,我对PHP的了解不多,这里有一张不好看的表!

我无法更改表格属性和样式,例如将其置于中心位置。

function reject(){
global $db_conn;    
$id =  mysql_real_escape_string($_GET['id']);   


$sql = "UPDATE message SET state='deny'
        where id='$id' ";
$result = mysql_query($sql,$db_conn) or die(mysql_error());

if($result)
    echo 'deny';
else
    echo 'error';

}
  ############
function show_all(){
global $db_conn;    



echo '<br><br>';
echo  '<table  border="2" > ';
echo '<tr>';
echo '<th>row</th>';
echo '<th>email</th>';  
echo '<th>place</th>';  
echo '<th>date</th>';   
echo '<th>time</th>';   
echo '<th>situation</th>';      
echo '<th>operation</th>';  


$sql = "select * from message where emailg='$_SESSION[valid_user]'";
$result = mysql_query($sql,$db_conn) or die(mysql_error());
$i=1;
while($row = mysql_fetch_array($result)){
    if($i%2==0)
        $class = 'class="even"';
    else
        $class = 'class="odd"';     
    echo '<tr '.$class.'>' ."\n" ;
    echo '<td>'.$i.'</td>'."\n";
    echo '<td>'.$row['emailf'].'</td>'."\n";    
    echo'<td>'.$row['location'].'</td>'."\n";   
    echo'<td>'.$row['date'].'</td>'."\n";
    echo'<td>'.$row['time'].'</td>'."\n";
    echo'<td>'.$row['state'].'</td>'."\n";                                      
    echo '<td><a href="'.$_SERVER['PHP_SELF'].'?op=accept&id='.$row['id'].'">accept</a>|<a href="'.$_SERVER['PHP_SELF'].'?op=reject&id='.$row['id'].'">deny </a>|<a href="'.$_SERVER['PHP_SELF'].'?op=delete&id='.$row['id'].'">delete</a></td>'."\n";          



    echo '</tr>'."\n";

    $i++;   
}



echo '</table>';
}
?>

【问题讨论】:

    标签: php html-table


    【解决方案1】:

    使用 css 进行视觉格式化。您只需在 html 代码中修改一件事。向您的表格添加一个 css 类:

    echo  '<table  border="2" class="pic"> ';
    

    并使用 CSS 自定义渲染。

    【讨论】:

    • 我做了这个,但是当我想添加类名时,它无法识别我的html代码中的类
    • 这是我的课:.pic { position: relative;左:60px;顶部:30px;背景颜色:#2e3e4e 边框:实心 1px #000;边框半径:50% }
    • 好的,但我在您的表格中看不到任何 .pic 类
    • 我想把这个类添加到表中,所以我的表得到了这些属性
    猜你喜欢
    • 2016-11-15
    • 2014-09-29
    • 1970-01-01
    • 1970-01-01
    • 2016-07-21
    • 2018-07-21
    • 1970-01-01
    • 2021-11-24
    • 1970-01-01
    相关资源
    最近更新 更多