-2
所以我想從我的數據庫中回顯一些數據。從mySQL數據庫將數據回顯到3x3網格
<?php
$connect = mysql_connect('xxxxx', 'xxxxx', 'xxxxx');
mysql_select_db("xxxxx", $connect) or die(mysql_error());
$lsql = "SELECT * FROM xxxxxxx ORDER BY Value DESC LIMIT 6";
$lquery = mysql_query($lsql) or die(mysql_error());
while ($lrow = mysql_fetch_array($lquery))
$lrows[] = $lrow;
foreach ($lrows as $lrow){
$ProperBrand = $lrow['ProperBrand'];
$LowerBrand = $lrow['LowerBrand'];
$PageTitle = $lrow['PageTitle'];
$PageH1 = $lrow['PageH1'];
$PageExcerpt = $lrow['PageExcerpt'];
$ContentP1 = $lrow['ContentP1'];
$ContentP2 = $lrow['ContentP2'];
$Image1 = $lrow['Image1'];
$Image2 = $lrow['Image2'];
$Image3 = $lrow['Image3'];
$BrandURL = $lrow['BrandURL'];
echo ('
<div class="col-sm-2">
<img src="'. $Image1 .'" class="top-images-larger">
</div>
');
}
?>
我可以附和它像上面那將正常工作,但我似乎無法弄清楚如何我將能夠與一個結構化的自舉行做到這一點。我想有一個9格上移動3×3的和已經做了類似下面的:
<div class="row visible-xs" align="center">
<div class="col-sm-4 padding-bottom">
<img src="/images/brandlogos/logo.png" class="top-images">
<img src="/images/brandlogos/logo.png" class="top-images">
<img src="/images/brandlogos/logo.png" class="top-images">
</div>
<div class="col-sm-4 padding-bottom">
<img src="/images/brandlogos/logo.png" class="top-images">
<img src="/images/brandlogos/logo.png" class="top-images">
<img src="/images/brandlogos/logo.png" class="top-images">
</div>
<div class="col-sm-4 padding-bottom">
<img src="/images/brandlogos/logo.png" class="top-images">
<img src="/images/brandlogos/logo.png" class="top-images">
<img src="/images/brandlogos/logo.png" class="top-images">
</div>
<div class="visible-xs col-sm-4 spacer-t">
<button type="button" class="btn btn-success btn-block">View All Stores</button>
</div>
</div>
如果我是爲了呼應就像我在上面的例子中都做到了將打破這種「網格」的結構。
在此先感謝。
爲什麼你使用一個不推薦的mysql api而不是mysqli或pdo與一個預先準備的語句,用戶輸入是否應該是圖片的一部分? –
你需要養成[接受答案](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)的習慣,它可以幫助你解決你的問題。您將獲得積分,其他人將被鼓勵幫助您。 –
**警告**:如果您只是學習PHP,請不要學習過時的['mysql_query'](http://php.net/manual/en/function.mysql-query.php)界面。這很糟糕,並且已經在PHP 7中被刪除了。像[PDO不是很難學的東西](http://net.tutsplus.com/tutorials/php/why-you-should-be-using-php-pdo- for-database-access /)以及[PHP The Right Way](http://www.phptherightway.com/)等指南有助於解釋最佳實踐。確保**你的用戶參數[妥善轉義](http://bobby-tables.com/php),否則你將以嚴重的[SQL注入漏洞](http://bobby-tables.com/ )。 – tadman