我尝试用上面的(主行)单元格来固定bootstrap中的单元格位置,但我不能
这是我的代码
<body>
<div class="container">
<table class="table table-striped table-bordered text-center" dir="rtl">
<tr>
<td >ردیف</td>
<td >عنوان</td>
<td >ویرایش</td>
<td >حذف</td>
</tr>
</table>
</div>
<?php
connect();
$news=mysql_query("select * from news");
while($row=mysql_fetch_array($news)){
$i++;
if($i %2 == 0)
$bg='#9999FF';
else
$bg='#fff';
echo '<div class="container">';
echo '<table class=" table table-striped table-responsive table-bordered text-center table-hover" dir="rtl">';
echo '<tr >';
echo '<td>'. $i.'</td>';
echo '<td>'. $row['title'].'</td>';
echo '<td ><a href="?link=nedit&ncod='.$row['ncod'].'"><i class="fa fa-edit fa-3x " ></i></a></td>';
echo '<td ><a href="?link=ndel&ncod='.$row['ncod'].'&npic='.$row['npic'].'"><i class="fa fa-trash fa-3x "style="color:red" ></i> </a> </td>';
echo '</tr> ';
echo '</table>';
echo '</div>';
}
?>
</body>
&#13;
我需要修复下面的细胞与上面的细胞进行比较
感谢
答案 0 :(得分:0)
您正在每行打开和关闭table
和div
,这就是原因;
在标题之前打开table
一次,而不是在循环之后关闭它一次。
<body>
<div class="container">
<table class="table table-striped table-bordered text-center" dir="rtl">
<tr>
<td >ردیف</td>
<td >عنوان</td>
<td >ویرایش</td>
<td >حذف</td>
</tr>
<?php
connect();
$news=mysql_query("select * from news");
while($row=mysql_fetch_array($news)){
$i++;
if($i %2 == 0)
$bg='#9999FF';
else
$bg='#fff';
echo '<tr >';
echo '<td>'. $i.'</td>';
echo '<td>'. $row['title'].'</td>';
echo '<td ><a href="?link=nedit&ncod='.$row['ncod'].'"><i class="fa fa-edit fa-3x " ></i></a></td>';
echo '<td ><a href="?link=ndel&ncod='.$row['ncod'].'&npic='.$row['npic'].'"><i class="fa fa-trash fa-3x "style="color:red" ></i> </a> </td>';
echo '</tr> ';
}?>
</table>
</div>
</body>
答案 1 :(得分:-2)
<body>
<?php
connect();
$news=mysql_query("select * from news");
echo '<div class="container">';
echo '<table class=" table table-striped table-responsive table-bordered text-center table-hover" style="white-space:nowrap; white-space-collapse:discard" dir="rtl">';
echo '<tr>';
echo '<th>ردیف </th> ';
echo '<th>عنوان</th> ';
echo '<th>ویرایش </th> ';
echo '<th>حذف</th> ';
echo '</tr>';
while($row=mysql_fetch_array($news)){
$i++;
if($i %2 == 0)
$bg='#9999FF';
else
$bg='#fff';
echo '<tr >';
echo '<td>'. $i.'</td>';
echo '<td>'. $row['title'].'</td>';
echo '<td ><a href="?link=nedit&ncod='.$row['id'].'"><i class="fa fa-edit fa-3x " ></i></a></td>';
echo '<td ><a href="?link=ndel&ncod='.$row['ncod'].'&npic='.$row['npic'].'"><i class="fa fa-trash fa-3x "style="color:red" ></i> </a> </td>';
echo '</tr> ';
}
?>
</table>
</div>