这里显示了来自数据库的所有记录,但是它首先显示所有空div,然后显示所有记录。我想显示每个记录显示在行中的单个div中。
<div id="winnercontainer">
<h2 style="background-color:#9966FF; width:850px; height:30px; font:bold; font- size:22px; color:#FFFFFF; padding-left:20px;">Winners</h2>
<?php
include('pagination/ps_pagination.php');
$conn = mysql_connect('localhost','root','');
if(!$conn) die("Failed to connect to database!");
$status = mysql_select_db('gunjanbid', $conn);
if(!$status) die("Failed to select database!");
$sql = 'SELECT * FROM winners';
$pager = new PS_Pagination($conn, $sql,10, 10);
//The paginate() function returns a mysql result set for the current page
$rs = $pager->paginate();
?>
<table>
<?php
while($row=mysql_fetch_array($rs)){
?>
<div id="winner">
<tr>
<td ><img src="memberpic/myphoto.jpg" width="150" height="150" alt="001" /></td>
<td > </td>
<td ><table >
<tr>
<td >Auction Item : <?php echo $row['Items']; ?></td>
</tr>
<tr>
<td>Rs. <?php echo $row['Rs']; ?></td>
</tr>
<tr>
<td>Winning Bid Value : Rs. <?php echo $row['WinningBidValue']; ?></td>
</tr>
<tr>
<td>MRP : Rs. <?php echo $row['MRP']; ?></td>
</tr>
<tr>
<td>Auction closed on : <?php echo $row['enddate']; ?></td>
</tr>
<tr>
<td>Winner : <?php echo $row['Winner']; ?></td>
</tr>
<tr>
<td>City: <?php echo $row['City']; ?></td>
</tr>
<tr>
<td >Delivery Status: <?php echo $row['DeliveryStatus']; ?></td>
</tr>
</table></td>
<td > </td>
<td id=save><font color=black>SAVED:</font> Rs.<?php echo $row['MRP']- $row['WinningBidValue']; ?></td>
<td > </td>
<td ><img src=productimage/1/1.1.jpg width="200" height="193" alt="001" /></td>
</tr>
</div>
<?php
}
?>
</table>
<?php
//Display the navigation
//echo $pager->renderFullNav();
echo '<div style="text-align:center">'.$pager->renderFullNav().'</div>';
?>
</div>
abd my stylesheet s are
#winnercontainer
{
width:870px;
height:auto;
background-color:#CCCCCC;
border:solid #9966FF;
border-radius:10px;
margin:auto;
clear:both;
margin:10px;
position:relative;
}
#winner
{
width:840px;
height:250px;
background-color: #999999;
border: solid #9966FF;
border-radius:10px;
margin:auto;
clear:both;
margin-top: 10px;
margin-right: 10px;
margin-bottom: 10px;
margin-left: 15px;
position:relative;
}
我希望我的所有记录都放在div中意味着每个div都有一条记录要显示.plz帮助我,我是新来的。
答案 0 :(得分:0)
我将开始介绍一些我从MySQL数据库读取表格并在屏幕上打印出来的旧代码。您可以根据需要进行修改。它是驻留在服务器上的php文件。
<?php
echo "<head><title>Read list</title></head>";
$host = "xxxxxxxxxxx";
$user = "xxxxxxxxxxx";
$password = "xxxxxxxxxxx";
$dbname = "xxxxxxxxxxx";
$cxn = mysqli_connect($host,$user,$password,$dbname);
if (mysqli_connect_errno()) {echo "No connection" . mysqli_connect_error();}
$query = " select * from list where uniqueid >= 0 ";
$result = mysqli_query($cxn, $query) or die ("could not query database");
echo "<table cellpadding=1px border=1>";
while ($row = mysqli_fetch_array($result))
{
$uniqueid = $row['uniqueid'];
$localid = $row['localid'];
$mdid = $row['mid'];
$type = $row['type'];
echo "<tr><td>".$uniqueid."</td><td>".$localid."</td><td>".$mdd."</td><td>".$type."</td></tr>";
}
echo "</table>";
?>