我需要將我的PHP數組轉換爲具有某個div類的html。將PHP數組轉換爲html
這裏是我的代碼:
<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
{ die('Could not connect: ' . mysql_error());
}
mysql_select_db("asd", $con);
$result = mysql_query("SELECT * FROM asd");
$something = array();
while ($row = mysql_fetch_assoc($result)) {
$something[] = array("title"=>$row['title'],
"name"=>$row['name'],
"content"=>$row['content'],
"image" =>
array(
"cls"=>"slide-image",
"_src"=>$row['src'],
"source"=>$row['source']
)
);
}
mysql_close($con);
?>
我想這樣
<div class="class1"> Here title goes</div>
Here name with some class
Here content with some class
任何幫助輸出嗎?
你嘗試過什麼嗎? – GolezTrol
while($ row = mysql_fetch_assoc($ result)){ echo「{$ row}」; } 我不知道它是正確還是錯誤。 – user1868475
你必須print_r($ row)或者說你想要哪一行索引。 echo $ row ['id_column']; –