2014-03-26 96 views
-1

這顯示從數據庫中的所有記錄,但它顯示了所有空div第一則下方顯示的所有記錄。我要顯示的每個記錄顯示在單格行。顯示在DIV數據庫表中的所有記錄在PHP

<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 >&nbsp;</td> 
<td ><table > 
    <tr> 
    <td >Auction Item :&nbsp;<?php echo $row['Items']; ?></td> 
    </tr> 
    <tr> 
    <td>Rs.&nbsp;<?php echo $row['Rs']; ?></td> 
    </tr> 
    <tr> 
    <td>Winning Bid Value : Rs.&nbsp;<?php echo $row['WinningBidValue']; ?></td> 
    </tr> 
    <tr> 
    <td>MRP : Rs.&nbsp;<?php echo $row['MRP']; ?></td> 
    </tr> 
    <tr> 
    <td>Auction closed on :&nbsp;<?php echo $row['enddate']; ?></td> 
    </tr> 
    <tr> 
    <td>Winner :&nbsp;<?php echo $row['Winner']; ?></td> 
    </tr> 
    <tr> 
    <td>City:&nbsp;<?php echo $row['City']; ?></td> 
    </tr> 
    <tr> 
    <td >Delivery Status:&nbsp;<?php echo $row['DeliveryStatus']; ?></td> 
    </tr> 
    </table></td> 
    <td >&nbsp;</td> 
    <td id=save><font color=black>SAVED:</font>&nbsp;Rs.<?php echo $row['MRP']- $row['WinningBidValue']; ?></td> 
    <td >&nbsp;</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都有一個記錄是display.plz幫助我,我是新來的。

+3

我的建議...首先學習html – slash197

+1

我希望''tr div id =「winner」>'只是一個錯字而不是實際的代碼。否則,要執行slash197說 – Kalzem

+0

@ slash197先生可我知道學習HTML的原因。 – user3419125

回答

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>"; 
?> 
+0

謝謝@TimSPQR – user3419125

相關問題