无法在php中使用css设置表格样式
我无法在css中设置表格的样式,即使我有表格的插入样式无法在php中使用css设置表格样式,php,css,Php,Css,我无法在css中设置表格的样式,即使我有表格的插入样式 <style> table, th, td { border: 1px solid black; } </style> 表,th,td { 边框:1px纯黑; } 以上是代码的简单样式 <div class="container"> <table class="u-full-width"> <?php $result=mysqli_query($c
<style>
table, th, td
{
border: 1px solid black;
}
</style>
表,th,td
{
边框:1px纯黑;
}
以上是代码的简单样式
<div class="container">
<table class="u-full-width">
<?php
$result=mysqli_query($connection,"SELECT * FROM register");
}
else
{
$result=mysqli_query($connection,"SELECT * FROM Persons WHERE username LIKE '".$Search."%'");
}
echo "<table border='1'>
<tr>
<th>username</th>
<th>password</th>
<th>Name</th>
<th>gender</th>
<th>age</th>
<th>Contact</th>
<th>address</th>
<th>email</th>
<th>occupation</th>
</tr>";
while($row=mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Username'] . "</td>";
echo "<td>" . $row['password'] . "</td>";
echo "<td>" . $row['Name'] . "</td> ";
echo "<td>" . $row['gender'] . "</td>";
echo "<td>" . $row['age'] . "</td> ";
echo "<td>" . $row['contact'] . "</td>";
echo "<td>" . $row['address'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['occupation'] . "</td>";
echo "</tr>";
}
echo"</table>";
mysqli_close($connection);
?>
</div>
</table>
这是因为您使用php动态插入表
试试这个
<div class="container">
<table class="u-full-width" border='1'>
<?php
if () {//note code is incomplete, might be copy pasting issue
$result=mysqli_query($connection,"SELECT * FROM register");
}
else
{
$result=mysqli_query($connection,"SELECT * FROM Persons WHERE username LIKE '".$Search."%'");
}
?>
<tr>
<th>username</th>
<th>password</th>
<th>Name</th>
<th>gender</th>
<th>age</th>
<th>Contact</th>
<th>address</th>
<th>email</th>
<th>occupation</th>
</tr>
<?php
while($row=mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Username'] . "</td>";
echo "<td>" . $row['password'] . "</td>";
echo "<td>" . $row['Name'] . "</td> ";
echo "<td>" . $row['gender'] . "</td>";
echo "<td>" . $row['age'] . "</td> ";
echo "<td>" . $row['contact'] . "</td>";
echo "<td>" . $row['address'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['occupation'] . "</td>";
echo "</tr>";
}
mysqli_close($connection);
?>
</table>
</div>
</table>
你可以很容易地设计风格。html的回声是一种糟糕的做法。所以kidly检查下面的方法
<table border='1'>
<tr>
<th>username</th>
<th>password</th>
<th>Name</th>
<th>gender</th>
<th>age</th>
<th>Contact</th>
<th>address</th>
<th>email</th>
<th>occupation</th>
</tr>
while($row=mysqli_fetch_array($result)){ ?>
<tr>
<td><?php echo $row['Username']; ?></td>
<td><?php echo $row['password']; ?></td>
<td><?php echo $row['Name']; ?></td>
<td><?php echo $row['gender']; ?></td>
<td><?php echo $row['age']; ?></td>
<td><?php echo $row['contact']; ?></td>
<td><?php echo $row['address']; ?></td>
<td><?php echo $row['email']; ?></td>
<td><?php echo $row['occupation']; ?></td>
</tr>
<?php } ?>
</table>
<?php mysqli_close($connection); ?>
?>
用户名
密码
名称
性别
年龄
接触
地址
电子邮件
职业
而($row=mysqli\u fetch\u数组($result)){?>
?>
在CSS中,您可以像以前一样使用
表,th,td
{
边框:1px纯黑;
}
希望这对您有所帮助!!!尝试在样式定义中添加背景,因为表格中的边框无法正常工作。您的html结构错误。请删除其中一个表格tag@Bhavik哪个表格标签?表格标签中有表格标签。请将其删除