从图片中可以看到:http://prntscr.com/78wcje
数据未显示在图像的顶部。
完整代码:http://pastebin.com/Z1ecden0
<h1>Pernix RsPs<br />
Official ItemDB!</h1>
<br />
<form action="search.php" method="POST">
<input type="text" name="search" /><br /><br />
<input type="Submit" value="Search ItemDB" />
</form>
<table border="0" width="400">
<img src="top.png"></table>
<table border="1" width="400">
<?php
$search = $_POST["search"];
MySQL_connect("localhost", "host", "pass");
MySQL_select_db("dbname");
$result = mysql_query("SELECT * FROM items WHERE name LIKE '%" . mysql_real_escape_string($search) . "%' ORDER by name") or trigger_error(mysql_error().$sql);
while($row = mysql_fetch_array($result))
{
?>
<?
echo '<tr>';
echo '<img src="post.png">';
echo '<td>' . $row['img'] . '</td>';
echo '<td>' . $row['name'] . '</td>';
echo '<td>' . $row['price'] . '</td>';
echo '</tr>';
}
}
?>
</table>
</center>
答案 0 :(得分:0)
只需在表格周围添加div,名称为theme
,如下所示
<div class="theme">
<table border="1" width="400">
<?php
$search = $_POST["search"];
MySQL_connect("localhost", "pernixr2_ge", "pass");
MySQL_select_db("pernixr2_ge");
$result = mysql_query("SELECT * FROM items WHERE name LIKE '%" . mysql_real_escape_string($search) . "%' ORDER by name") or trigger_error(mysql_error().$sql);
while($row = mysql_fetch_array($result))
{
?>
<?
echo '<tr>';
echo '<img src="post.png">';
echo '<td>' . $row['img'] . '</td>';
echo '<td>' . $row['name'] . '</td>';
echo '<td>' . $row['price'] . '</td>';
echo '</tr>';
}
}
?>
</table>
</div>
在.css
文件中添加此代码
.theme-table, .theme {
height: 100%;
width: 100%;
}
.theme-table {
border:1px solid black;
table-layout: fixed;
}
.theme {
background:url(http://www.psdgraphics.com/wp-content/uploads/2012/04/light-wooden-background.jpg);
background-repeat:no-repeat;
}
注意:
将图片的网址替换为top.png
或您想要的任何图片
更新:
由于mysql被折旧,我已经使用mysqli给出了代码,其内部有样式
<?php
$Connection = new mysqli("localhost", "root", "", "mysqli");
if ($Connection->connect_errno)
{
echo "Connection Failed".$Connection->connect_error;
exit();
}
$query = "SELECT * from users";
if ($result = $Connection->query($query)) {
?>
<div class="theme">
<style type="text/css">
.theme {
background:url(http://www.psdgraphics.com/wp-content/uploads/2012/04/light-wooden-background.jpg);
background-repeat:no-repeat;
}
</style>
<table style="width:45%" border="1">
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<?php
while ($row = $result->fetch_assoc())
{
echo "
<tr>
<td>".$row["id"]."</td>
<td>".$row["username"]."</td>
<td>".$row["username"]."</td>
</tr>
";
}
$result->free();
}
?>
</table>
</div>
<?php
$Connection->close();
?>
以下是Image