2012-04-10 59 views
-6

我有一個問題,並沒有解決。用php上市照片

What i want is that listing photos side to side 

這樣的:

enter image description here

The problem is that when i have 50 photos , this happens 

enter image description here

什麼,我想的是,上市每列10張照片。我怎樣才能做到這一點 ?

+0

什麼是你的css /瀏覽器/ html – 2012-04-10 13:20:16

+0

這是一個顯示(風格)問題或PHP? – 2012-04-10 13:45:12

回答

1

當循環顯示您需要打破每10張照片,像這樣的圖片:一個具有指定寬度

$photosPerLine = 10; 
for (var $i = 0; $i < $totalNumPhotos; $i++) 
{ 
    drawPhoto(); // This does the actual drawing - perhaps echo a <IMG> or whatever 

    // Now we check if we've reached 10 in a row, we do this by dividing the 
    // photo counter by 10 and checking for a reminder, only numbers in leaps 
    // of 10 will divide without a reminder. If we don't have a reminder it means 
    // we're at 10, 20, 30 ... so we break the line 

    if (($i + 1) % $photosPerLine == 0) 
    { 
     echo('<br/>'); // Or create a new row in a table or whatever 
    } 
} 

或者只是放置圖像在一個容器(<div>例如)持有恰好10圖像和讓瀏覽器斷行以適應內容。