ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

Ãö©ó mysql_fetch_assoc()

Ãö©ó mysql_fetch_assoc()

ª©¤Wªº¦U¦ì¤j¤j§A­Ì¦n¡G

¤pªº§Ú³Ìªñ½m²ßphp¡A¹J¨ì¤F¥H¤U°ÝÃD¡G

³sµ²mysql§Ú­n¿é¥X¾Ç¥Íªº¸ê®Æ¥[¤À­¶¡Aµ²ªG·|¥X²{¥H¤U¿ù»~¡A¦p¤U¹Ï¡G



¥H¤U¬O§Úªºµ{¦¡¤º®e¡G

·Q½Ðª©¤Wªº¤j¤j­ÌÀ°§Ú¬Ý¤@¤U§Ú­þ¸Ì¥X¿ù¤F¡A§Ú¬O«ö·Ó®Ñ¤W¥´¡A¬°¤°»ò¿é¥X«á·|¥X²{¿ù»~¡C

¸ê®Æ®w¦³³s¤W¡A­¶¦¸ªº¥\¯à¤]¦³¥¿±`¡A¦ý¾Ç¥Í¦¨ÁZªíªº³¡¥÷´N¬O¥X¤£¨Ó...:'(

===================================================================================

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<?
include("connMysql.php");
?>


<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />

<link href="style.css" rel="stylesheet" type="text/css"/>

</head>

<body>



<?

$seldb=@mysql_select_db("class");

if(!$seldb) die("¸ê®Æ®w¿ï¾Ü¥¢±Ñ");

$sql_query="SELECT * FROM `student`";

$pageRow_records=3; //¨C­¶Åã¥Üµ§¼Æ

$num_pages=1; //¹w³]¿Ã¹õ©Ò¦b­¶¼Æ

if(isset($_GET['page'])){

$num_pages=$_GET['page'];

}

//¶}©l°O¿ýµ§¼Æ

$startRow_records = ($num_pages -1) * $pageRow_records;

$sql_query_limit=$sql_query. "LIMIT". $startRow_records. ",". $pageRow_records;

$result=mysql_query($sql_query_limit);

$all_result=mysql_query($sql_query);

$total_records=mysql_num_rows($all_result);

$total_pages=ceil($total_records/$pageRow_records);

?>

<p>¥Ø«e¾Ç¥ÍÁ`¤H¼Æ¬°¡G<? echo $total_records; ?></p>

<p><a href="add.php">[·s¼W¾Ç¥Í¸ê®Æ]</a></p>

<div class="listbox">

<div class="list">®y¸¹</div>
<div class="list">©m¦W</div>
<div class="list">©Ê§O</div>
<div class="list">¥Í¤é</div>
<div class="list1">email</div>
<div class="list">¹q¸Ü</div>
<div class="list">¦í§}</div>
<div class="list">­×§ï</div>
<div class="list">§R°£</div>

</div>

<?

while($row_result=mysql_fetch_assoc($result)){

echo "<div class='listbox'>";

echo "<div class='list'>". $row_result['cID']. "</div>";
echo "<div class='list'>". $row_result['cName']. "</div>";
echo "<div class='list'>". $row_result['cSex']. "</div>";
echo "<div class='list'>". $row_result['cBirthday']. "</div>";
echo "<div class='list1'>". $row_result['cEmail']. "</div>";
echo "<div class='list'>". $row_result['cPhone']. "</div>";
echo "<div class='list'>". $row_result['cAddr']. "</div>";

echo "<div class='list'><a href='delete.php?id=". $row_result['cID']. "'>§R°£</a></div>";
echo "<div class='list'><a href='update.php?id=". $row_result['cID']. "'>­×§ï</a></div>";


echo "</div>";

}

?>

<? echo "<div class='listbox'>"; ?>

<? if($num_pages>1){ ?>

<div class="list"><a href="index.php?page=1">²Ä¤@­¶</a></div>
<div class="list"><a href="index.php?page=<? echo $num_pages-1; ?>">¤W¤@­¶</a></div>
<? } ?>

<? if (num_pages<$total_pages){ ?>
<div class="list"><a href="index.php?page=<? echo $num_pages+1; ?>">¤U¤@­¶</a></div>
<div class="list"><a href="index.php?page=<? echo $total_pages; ?>">³Ì«á­¶</a></div>

<? } ?>

<? echo "</div>";?>

</body>

</html>
Learn Learn Learn

  1. $sql_query="SELECT * FROM `student`";
  2. $sql_query_limit=$sql_query. "LIMIT". $startRow_records. ",". $pageRow_records;
½Æ»s¥N½X
À°§A¬D¥X¨Ó,$sql_query_limit·|¬O¬Æ»ò©O?
"SELECT * FROM `student`LIMIT". $startRow_records. ",". $pageRow_records;
¬O¤£¬O¤Ö¤FªÅ®æ??
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

¦^´_ 2# ¤p»x

¤p»x¤j¡A§Ú«á¨Ó¨Ï¥Î¥L®Ñªþªº¥úºÐ¡A

¤]¬O¦P¼Ëªº±¡§Î¡C

ÃhºÃ¬O®Ñ¤¤ªº¤º¤å¦³»~¡A

§Ú¤w¥tÁÊ¥t¤@¥Xª©ªÀªº®Ñ¡A

¦A°Ñ¦Ò¤p»x¤j¦b½×¾Â¼gªºPHP±Ð¾Ç¡C

§Æ±æ¦³´Â¤@¤é¯à¿Ä·|PHP¡C

ÁÂÁ¤p»x¤j²Ó¤ßªº«ü¾É¡C

:D
Learn Learn Learn

TOP

        ÀR«ä¦Û¦b : §Ú­Ì­n°µ¦nªÀ·|ªºÀô«O¡A¤]­n°µ¦n¤º¤ßªºÀô«O¡C
ªð¦^¦Cªí ¤W¤@¥DÃD