PHP ???? ?? ?? ???? ?? ?? ??
?? ????? ?? ?? ?? ??? ??????. ?????? ?? ? ??? ??? ???? ??? ?? ???? ?? ?? ???? ??? ??? ???????. ?? ?? ?? ????? ???? ?? ???? ?? ?? ????? ???? ??? ?????.
???? ???? ??? ? ???? ??? ?????. ?? ??????? ?????:
<?php error_reporting(E_ALL & ~E_NOTICE ); // 連接mysql數(shù)據(jù)庫(kù) $link = mysqli_connect('localhost', 'root', 'root'); if (!$link) { echo "connect mysql error!"; exit(); } // 選中數(shù)據(jù)庫(kù) news為數(shù)據(jù)庫(kù)的名字 $db_selected = mysqli_select_db($link, 'news'); if (!$db_selected) { echo "<br>selected db error!"; exit(); }
?? ?? ??????? ???? SQL ?? ?????.
$sql = "select * from new_category where 1 "; // 查詢語(yǔ)句 $result = mysqli_query($link, $sql); $arr_news_category = mysqli_fetch_all($result, MYSQL_ASSOC);
??? ?? ??? ??????. ?? ??? ???? ???? ???? ???.
<table class="table table-hover text-center"> <tr> <th width="5%">ID</th> <th width="15%">分類名</th> <th width="10%">操作</th> </tr> <?php if (count($arr_news_category) > 0) { foreach ($arr_news_category as $val) { echo "<tr>"; echo "<td>{$val['id']}</td>"; echo "<td>{$val['name']}</td>"; ?> <td> <div class='button-group'> <a class='button border-main' href='category_edit.php?id=<?php echo $val['id'];?>'> <span class='icon-edit'></span> 修改</a> <a class='button border-red' href='javascript:;' onclick='return del(<?php echo $val['id']?>)'> <span class='icon-trash-o'></span> 刪除</a> </div> </td> <? echo " </tr>"; } } else { echo "<tr><td colspan='3' align='center'>暫無(wú)記錄!</td></tr>"; } ?>
OK! ?? ?? ??? ???????. ? ?! ???? ??? ??? ????. ???? ?? ??? ??? ???? ?????.