2013-04-07 54 views
0

請誰能告訴我什麼是錯在我的PHP代碼,我想顯示mysql的結果分爲3列例如:顯示Mysql的結果在3列

POST1 POST2 post3
post4 post5 post6
post7 post8 post9

這裏是我的代碼: -

$rowsql = "SELECT * FROM status WHERE account_name='$profile_user' ORDER BY postdate DESC LIMIT 0,20"; 
$rowquery = mysqli_query($db_conx, $rowsql); 
$rowstatusnumrows = mysqli_num_rows($rowquery); 
$i=1; 
$x=1; 
$y=2; 
$z=3; 
while ($rowrow = mysqli_fetch_array($rowquery, MYSQLI_ASSOC)) { 

$statusid = $rowrow["id"]; 
$account_name = $rowrow["account_name"]; 
$author = $rowrow["author"]; 
$postdate = $rowrow["postdate"]; 
$statusimg = $rowrow["img"]; 
$statusvideo = $rowrow["video"]; 
$data = $rowrow["data"]; 
$data = nl2br($data); 
$data = str_replace("&","&",$data); 
$data = stripslashes($data); 
$statusDeleteButton = ''; 

if($author == $log_username || $account_name == $log_username){ 
$statusDeleteButton .= ''; 
} 
if($statusimg == ""){ 
    $thereisstatusimg = ""; 
} 
else 
{ 
    $thereisstatusimg = "<img width='260' height='130' src='".$statusimg."' />"; 
    $thereisstatusvideo = ""; 
} 

if($statusvideo == ""){ 
    $thereisstatusvideo = ""; 
} 
else 
{ 
    $thereisstatusvideo = "<iframe width='260' height='130' src='".$statusvideo."'></iframe>"; 
    $thereisstatusimg = ""; 
} 

    $mycolumns[$i] .= "<div class='tile2' style='margin-bottom:10px; width:260px; min-height:80px; max-height:350px; background:#789600;'><div style='height:45px;'><img width='30' height='30' style='float:left; margin-top:10px; margin-bottom:10px; margin-left:10px; border-radius:15px 15px 15px 15px;' src='img/attach_1.jpg' /><div class='tile2Title' style='font-size:14px; margin-top:15px; float:left;'>".$author."</div></div>".$thereisstatusimg."".$thereisstatusvideo."<div class='tile2Desc' style='margin-top:5px; margin-bottom:5px; text-decoration: none'>".$data."</div></div>"; 

    if($i=$x){$i=1;} 
    if($i=$y){$i=2;} 
    if($i=$z){$i=3;} 

    $i++; 
    $x+3; 
    $y+3; 
    $z+3; 
    } 

,並非常感謝....

回答

0

您需要輸出html代碼來創建表格。

<table name="asdf"> 
<tr> <td> stuff1 </td><td>stuff2</td><td>stuff3</td> 
<tr> 

</table>