亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

自定義模板 ,格式化輸出數(shù)據(jù)庫的數(shù)據(jù)

Original 2019-07-11 15:46:23 214
abstract:<?php //創(chuàng)建PDO對象 連接數(shù)據(jù)庫 $pdo = new PDO('mysql:host=127.0.0.1;dbname=sanguozhi','root','root'); //創(chuàng)建預(yù)處理對象 $sql = 'SELECT `w_id`,`w_name
<?php

//創(chuàng)建PDO對象 連接數(shù)據(jù)庫
$pdo = new PDO('mysql:host=127.0.0.1;dbname=sanguozhi','root','root');

//創(chuàng)建預(yù)處理對象
$sql = 'SELECT `w_id`,`w_name`,`force`,`arms` FROM `warriors` WHERE `healthy`=:healthy';

$stmt = $pdo->prepare($sql);

$stmt->execute([':healthy'=>1]);

//遍歷
$rows = [];
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
	$rows[] = $row;
}
print_r($rows);


?>
<style>
	table,th,td{
		border:1px solid #333;
	}
	
	table{
		text-align:center;
		border:1px solid #333;
		width:50%;
		margin:30px auto;
		border-collapse:collapse;		
	}
	
	table caption{
		font-size:1.5em;
		font-weight:bolder;
		margin-bottom:15px;
	}
	
	table tr:first-chile{
		background-color:lightblue;
	}
</style>

<table>
<caption>武將資料</caption>
 <tr>
	<th>ID</th>
	<th>武將姓名</th>
	<th>武力</th>
	<th>兵種</th>
 </tr>
	<?php foreach ($rows as $row):?>
	<tr>
		<td> <?php echo $row['w_id']?></td>
		<td> <?php echo $row['w_name']?></td>
		<td> <?php echo $row['force']?></td>
		<td> <?php echo $row['arms']?></td>
	</tr>
	<?php endforeach;?>

</table>


Correcting teacher:天蓬老師Correction time:2019-07-13 13:15:06
Teacher's summary:模板語法, 寫得非常的專業(yè), 不錯的.....

Release Notes

Popular Entries