更改 echo table 属性
Change echo table properties
我这里有紧急情况;我的朋友就这样完成了我的代码,我知道的不多PHP,这里有一个看起来不太好看的table!
我无法更改 table 属性和样式,例如将其置于中心。
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>';
}
?>
使用 css 进行视觉格式化。您只需要修改 html 代码中的一件事。添加一个 css class 到你的 table :
echo '<table border="2" class="pic"> ';
并使用 CSS 自定义渲染。
我这里有紧急情况;我的朋友就这样完成了我的代码,我知道的不多PHP,这里有一个看起来不太好看的table!
我无法更改 table 属性和样式,例如将其置于中心。
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>';
}
?>
使用 css 进行视觉格式化。您只需要修改 html 代码中的一件事。添加一个 css class 到你的 table :
echo '<table border="2" class="pic"> ';
并使用 CSS 自定义渲染。