ȸ¿ø·Î±×ÀÎ
13³â Àü
ÀÚ.....Áö³½Ã°£¿¡....
¸Þ¸ðÀÔ·Ââ±îÁö ¸¸µé°í ÀԷ±îÁö µÇµµ·Ï ¸¸µé¾î º¸¾Ò½À´Ï´Ù...
±Ùµ¥ ÀÔ·ÂÀº µÇ´Âµ¥ ÀÔ·ÂÇÑ ³»¿ëÀÌ È¸é¿¡ Ç¥½ÃµÇÁö´Â ¾Ê¾ÒÁÒ?
¾ÆÁ÷ ²¨³»¿À±â¸¦ ¾ÈÇؼ ±×·¸½À´Ï´Ù...-_-;
(php my adminÀ¸·Î exam_memo¶ó´Â Å×À̺íÀÇ ÀϹÝÀû¸®½ºÆ®¸¦ È®ÀÎÇϽøé ÀÔ·ÂÇÑ ¸Þ¸ðµéÀÌ º¸ÀÏ°Ì´Ï´Ù....)
ÀÚ ±×·³ ÀÌÁ¦ ²¨³»¿À±â¸¦ ÇØ¾ß Çϴµ¥.....
DB¿¡¼ ²¨³»¿À´Â Äõ¸®´Â select¶ó´Â ±¸¹®À» »ç¿ëÇÕ´Ï´Ù...
sqlÀÇ ±âº»±¸¹®ÀÌÁÒ;;;
select [²¨³»¿ÃÇ׸ñ] from [²¨³»¿ÃÅ×À̺í] where [Á¶°Ç] order by [Á¤·Ä¹æ¹ý] limit [°¹¼ö]
À§¿Í °°Àº ±âº»Çü½ÄÀÔ´Ï´Ù...
»ç½Ç Á»´õ º¹ÀâÇÑ ¿É¼ÇÀÌ ´õ µé¾î°¡´Âµ¥....ÀÏ´Ü »ç¿ëÇÒ °Íµé¸¸ Àû¾î ³õ¾ÆºÃ½À´Ï´Ù...
¾Æ¹«·¡µµ Äõ¸®¹®¿¡ ´ëÇؼ µû·Î °øºÎ ÇÏ¼Å¾ß ÇÒ°Í°°Àºµ¥....ÈìÈì...
±×·³ ÀÌÁ¦ ¿ì¸®°¡ ¸¸µç Å×ÀÌºí¿¡ Àû¿ëÇغ¼±î¿ä...
select * from exam_memo
À§ ±¸¹®¿¡¼ *¶õ...¸ðµç°ÍÀ̶õ ¶æÀÔ´Ï´Ù...¾îµð¿¡¼? from exam_memo
Áï, exam_memo¶ó´Â Å×ÀÌºí¿¡¼ ¸ðµç°Í(*)À» ²¨³» ¿À¶ó´Â°ÅÁÒ...
whereÀýÀÌ ¾ø´Â ÀÌÀ¯´Â ¾Æ¹«·± Á¶°ÇÀÌ ¾ø±â ¶§¹®ÀÔ´Ï´Ù....±×¾ß¸»·Î Àִ´ë·Î ÁË´Ù ²¨³»¿À´Â°ÅÁÒ...
select * from exam_memo order by no
order byÀý¿¡¼ no·Î ÁÖ¾ú½À´Ï´Ù......±×·¡¼ ÀÌÄõ¸®·Î ²¨³»¿À¸é no¼øÀ¸·Î ²¨³»¿É´Ï´Ù.
¿ì¸®°¡ Å×À̺íÀ» ¸¸µé¶§ no¶ó´Â Ç׸ñÀ» ¸¸µé¾ú¾úÁÒ....
ÀÚµ¿À¸·Î Áõ°¡µÇ±â ¶§¹®¿¡ 1,2,3,... ÀÌ·±½ÄÀ¸·Î Áõ°¡ÇßÀ»°ÍÀÔ´Ï´Ù.
±×·±µ¥ no¼øÀ¸·Î ²¨³»¿À¸é °¡Àå ¿À·¡Àü±Û ºÎÅÍ ºÒ·¯¿À°ÚÁÒ......
ÇÏÁö¸¸ º¸Åë ¸Þ¸ðÀåÀ̳ª ±×·±°ÍµéÀº °¡Àå ÃÖ±Ù±ÛºÎÅÍ ²¨³»¿Â´ÙÁÒ~
±×·¡¼ µÚ¿¡ desc¶ó´Â°É ºÙÀÔ´Ï´Ù....¿ª¼ø...À̶ó´Â ¾ê±âÁÒ.......³»¸²Â÷¼ø!
asc¿Í desc°¡ Àִµ¥ asc´Â »ý·«ÇÒ¼ö ÀÖ½À´Ï´Ù. ±×·¡¼ order by no¶ó°í¸¸ Çß´Ù¸é
order by no asc¿Í °°Àº ¸»ÀÔ´Ï´Ù. noÀÇ ¿Ã¸²Â÷¼øÀ¸·Î ²¨³»¿Â´Ù´Â °ÅÁÒ..
ÇÏÁö¸¸ order by no desc¶ó°í Çϸé noÀÇ ³»¸²Â÷¼øÀ¸·Î ²¨³»¿É´Ï´Ù.
select * from exam_memo order by no desc limit 10
limit 10À̶ó´Â°ÍÀº noÀÇ ³»¸²Â÷¼øÀ¸·Î 10°³¸¸ °¡Á®¿Â´Ù´Â °ÍÀÔ´Ï´Ù.
¸Þ¸ð°¡ 100°³°¡ Àִµ¥ ÇÑÆäÀÌÁö¿¡ ¸ðµÎ 100°³¸¦ º¸¿©ÁÖ´Â°Ç ¹«¸®°ÚÁÒ...
±×·¡¼ ÆäÀÌÁö¸¦ ³ª´©°í ÇÑÆäÀÌÁö¿¡ µé¾î°¥ °¹¼ö¸¸Å °¡Á®¿À´Â °Ì´Ï´Ù...ÀÏ´Ü 10°³·Î Çߴµ¥...
óÀ½ 10°³¸¦ °¡Á®¿Â´Ù´Â °Å°ÚÁÒ?...±×·³ ´ÙÀ½ 10°³´Â ¾î¶»°Ô °¡Á®¿À³ª¿ä?....
ÀÌ·¸°Ô ¹Ù²ãº¾½Ã´Ù...
select * from exam_memo order by no desc limit 10,10
limit [½ÃÀÛÀ§Ä¡],[°¹¼ö]
ÀÌ·¸°Ô Çϸé 11¹ø° ±ÛºÎÅÍ 10°³¸¦ °¡Á®¿Â´Ù´Â°ÍÀÔ´Ï´Ù. ±×·¯´Ï±î 2¹ø° ÆäÀÌÁö°¡ µÇ°ÚÁÒ...
±×·³ ¿©±â¼ ÆäÀÌÁö ³ª´©´Â ¹æ¹ý¿¡ ´ëÇؼ Àá±ñ;;;
Á» @_@º¹ÀâÇϱä ÇÏÁö¸¸ Â÷±ÙÂ÷±Ù »ý°¢Çغ¸¸é.....±×¸® ¾î·ÆÁø ¾ÊÀ»°Ì´Ï´Ù...
-_-;Àúµµ ÀÌ ·ÎÁ÷À» »ý°¢ÇÏ´À¶ó ¾îÂ ¸¹Àº »ðÁúÀ» Çß´ÂÁö...
ÀÚ º¸½ÃÁÒ~
Àüü 39°³ÀÇ ±ÛÀÌ ÀÖ½À´Ï´Ù....
ÇÑÆäÀÌÁö¿¡ 10°³ÀÇ ±ÛÀÌ º¸¿©Áø´Ù¸é ÃÑ ¸îÆäÀÌÁö°¡ ÇÊ¿äÇÒ±î¿ä? °è»êÇØ º¸¼¼¿ä....
³×¿¡ 4ÆäÀÌÁöÁÒ....39/10=3...9
3ÆäÀÌÁö¸¦ ¾²°í 9°³ÀÇ ±ÛÀÌ ³²½À´Ï´Ù....ÇÏÁö¸¸ ÀÌ ³ª¸ÓÁö 9°³µµ ÇÑ°³ÀÇ ÆäÀÌÁö¸¦ ¾²°ÚÁÒ....
³ª¸ÓÁö°¡ 1À̾ ¹°·Ð ÇÑ°³ÀÇ ÆäÀÌÁö¸¦ ´õ ¾²°Ô µË´Ï´Ù...
°á±¹ ÃÑ ¸îÆäÀÌÁöÀΰ¡¸¦ ±¸ÇÏ´Â ½ÄÀº....
ÀüüÆäÀÌÁö¸¦ ÆäÀÌÁö´ç °¹¼ö·Î ³ª´«¸òÀ» ¹«Á¶°Ç ¿Ã¸² ÇØÁØ°ªÀÌ µË´Ï´Ù.
php¿¡¼ ¿Ã¸²°ªÀ» ¸®ÅÏÇÏ´Â ÇÔ¼ö´Â ceil()ÀÔ´Ï´Ù
¾Æ·¡¿Í °°Àº ½ÄÀÌ ³ª¿À°ÚÁÒ...
//ÆäÀÌÁö¼ö ±¸Çϴ°ø½Ä
//$total Àüü°¹¼ö
//$page ÆäÀÌÁö´ç °Ô½Ã¹°¼ö
$pagesu = ceil($total/$page); //Àüü°¹¼ö¸¦ ÆäÀÌÁö´ç °Ô½Ã¹°¼ö·Î ³ª´²¼ ¿Ã¸²
ÀÚ ±×·³ ´ëÀÔÇغ¼±î¿ä?
$total=39;
$page=10;
$pagesu=ceil($total/$page);
°á°ú´Â $pagesu=4°¡ µË´Ï´Ù......¸ÂÁÒ?
±×·³ Àüü 4°³ÀÇ ÆäÀÌÁö°¡ ³ª¿Â´Ù´Â ¾ê±â°ÚÁÒ....
±×·³ÀÌÁ¦ ÆäÀÌÁö¸¦ ±¸ºÐÇØ ÁÖ´Â º¯¼ö¸¦ Çϳª ¸¸µé¾î º¸ÁÒ...
$pagenumÀ̶ó°í ÇÏ°Ú½À´Ï´Ù (-_-ÁåÀ帾´ë·Î)
$pagenumÀÌ 0À̸é...Áï °ªÀÌ µé¾îÀÖÁö ¾ÊÀ¸¸é ùÆäÀÌÁö¸¦ º¸¿©ÁÖ°Ô ÇÏ°í....
1ÀÌ¸é µÎ¹ø° ÆäÀÌÁö....2ÀÌ¸é ¼¼¹ø° ÆäÀÌÁö¸¦ º¸¿©ÁÖ°Ô Çغ¼±î¿ä...
ÀÚ ±×·³ ÀÓÀÇ·Î $pagenumÀ» Á¤ÇØ Á־°Ú½À´Ï´Ù @_@´« Å©°Ô ¶ß½Ã°í...
$pagenum=2; //¼¼¹ø° ÆäÀÌÁö¸¦ º¸¿©ÁÝ´Ï´Ù.
$total=39; //Àüü°¹¼ö
$page=10; //ÆäÀÌÁö´ç °¹¼ö
$pagesu=ceil($total/$page); //ÆäÀÌÁö¼ö¸¦ ±¸ÇÕ´Ï´Ù. °á°ú:4
Àüü 4°³ÀÇ ÆäÀÌÁö°¡ ³ª¿Ô°í ¼¼¹ø°ÆäÀÌÁö¸¦ º¸±â¸¦ ¿øÇÕ´Ï´Ù.
Äõ¸®¹®¿¡¼´Â limit [½ÃÀÛÀ§Ä¡],[°¹¼ö]
½ÃÀÛÀ§Ä¡¸¦ Àâ¾ÆÁà¾ß°ÚÁÒ...°¹¼ö´Â $pageÀÔ´Ï´Ù.(ÆäÀÌÁö´ç °¹¼ö´Ï±î¿ä)
½ÃÀÛÀ§Ä¡´Â ¾Æ·¡¿Í °°Àº ½ÄÀ¸·Î ÀâÀ¸¸é µÇ°Ú쬬~
$start=($page*$pagenum);
´ëÀÔÇØ º¾½Ã´Ù.....
ÃÖÃÊ....ù¹ø° ÆäÀÌÁö¸¦ º¼¶§´Â $pagenum=0ÀÔ´Ï´Ù. À§½Ä¿¡ ´ëÀÔÇغ¸¸é $start=0ÀÌÁÒ...
±×·¡¼ Äõ¸®¹®Àº limit 0,10ÀÌ µË´Ï´Ù.
¸ÂÁÒ? ù¹ø°±ÛºÎÅÍ 10°³.....
$pagenum=1À϶§......´ëÀÔÇغ¸¸é (10*1)=10
limit 10,10ÀÔ´Ï´Ù.....11¹ø°±ÛºÎÅÍ 10°³
$pagenum=2À϶§......´ëÀÔÇغ¸¸é (10*2)=20
limit 20,10ÀÔ´Ï´Ù.....21¹ø°±ÛºÎÅÍ 10°³
....
ÀÚ ÀÌ·±½ÄÀ¸·Î ³ª¿À°Ô µÇ°Ú쬬....
Á¤¸®Çغ¾½Ã´Ù....¾Æ·¡ ¼Ò½º¸¦ º¸¼¼¿ä...
$pagenum=2; //¼¼¹ø° ÆäÀÌÁö¸¦ º¸¿©ÁÝ´Ï´Ù.
$total=39; //Àüü°¹¼ö
$page=10; //ÆäÀÌÁö´ç °¹¼ö
$pagesu=ceil($total/$page); //ÆäÀÌÁö¼ö¸¦ ±¸ÇÕ´Ï´Ù. °á°ú:4
$start=($page*$pagenum); //°¡Á®¿Ã ½ÃÀÛÀ§Ä¡¸¦ °áÁ¤ÇÕ´Ï´Ù.
Äõ¸®¹®=select * from exam_memo order by no desc limit $start,$page
À§ ½Ä¿¡¼ °Ô½Ã¹°À» °¡Á®¿Ã ½ÃÀÛÀ§Ä¡¿Í °¹¼ö¸¦ $start¿Í $page·Î ¹Þ¾Æ¼ Äõ¸®¿¡ ³Ö¾îÁØ°ÍÀÔ´Ï´Ù.
ÀÌ·¸°Ô Çϸé $pagenum¿¡ µû¶ó ÆäÀÌÁö°¡ ¹Ù²î°ÚÁÒ...ÇäÇä.....
(ÀÌÇØ°¡ ¾È°¡½Ã¸é ´Ù½Ã Àß ¸Ó¸´¼ÓÀ¸·Î ¾Ï»êÀ» ÇÏ¸é¼ º¸¼¼¿ä...)
±×·³ ÆäÀÌÁö¼ö °áÁ¤ÇÏ´Â°Ç ¿©±â±îÁö¸¸ ÇÏ°í......
ÀÌÁ¦ ±Û¸ñ·ÏÀ» °¡Á®¿À´Â ºÎºÐ¿¡ ´ëÇؼ Çغ¸µµ·Ï ÇÏÁÒ....
¿ì¼± °Ô½Ã¹°ÀÇ Àüü°¹¼ö¸¦ ±¸Çؾ߰ÚÁÒ....
±¸ÇÏ´Â Äõ¸®´Â ¾Æ·¡¿Í °°½À´Ï´Ù...
select count(*) from [Å×À̺íÀ̸§]
count()¶ó´Â ÇÔ¼ö´Â mysql¿¡¼ Á¦°øµÇ´Â ÇÔ¼öÀÔ´Ï´Ù(php¶ûÀº »ó°ü¾ø½À´Ï´Ù)
¿ÀÇ °¹¼ö¸¦ ¼¼´Â°ÅÁÒ.... ±×·¯´Ï±î ÃÑ ¿ÀÇ °¹¼ö¸¦ ±¸ÇÏ°í ±×°ÍÀ» selectÇØÁÝ´Ï´Ù.
´ëÀÔÇØ º¼±î¿ä?
select count(*) from exam_memo
ÀÌ·¸°Ô µÇ°ÚÁÒ....
±×·³ php·Î Àû¿ëÇغ¸ÁÒ...
$query="select count(*) from exam_memo"; //Äõ¸®¹®ÀúÀå
$total=mysql_fetch_array(mysql_query($query)); //Äõ¸®¹®ÀÔ·Â
$total=$total["count(*)"]; //°¹¼öÀúÀå
ù°ÁÙ¿¡¼ $query¶ó´Â º¯¼ö¿¡ Äõ¸®¹®À» ³Ö°í µÎ¹ø° ÁÙ¿¡¼ mysql_query()ÇÔ¼ö·Î mysql·Î º¸³À´Ï´Ù.
±×¸®°í ¿©±â¼ mysql_fetch_array()¶ó´Â ÇÔ¼ö´Â selectµÈ °ªÀ» ¿¬°ü¹è¿·Î ¸®ÅÏÇÕ´Ï´Ù.
¿¬°ü¹è¿À̶õ......Áö³¹ø¿¡ ¹è¿À» ´Ù·ê¶§ ³ª¿Ô´ø °ÍÀÌÁÒ...
º¸Åë ¹è¿Ã³·³ $a[0],$a[1]ÀÌ ¾Æ´Ï¶ó $a[name],$a[title] °ú °°ÀÌ ¹è¿¾È¿¡ ¼ýÀÚ ´ë½Å ÀÓÀÌÀÇ ´Ü¾î·Î ±¸ºÐÇÏ°Ô ÇØÁÝ´Ï´Ù.
mysql_fetch_array()¸¦ »ç¿ëÇϸé selectµÈ Ç׸ñÀÌ ¿¬°ü¹è¿·Î µé¾î°©´Ï´Ù.
select * ·Î ÇØÁÖ¾ú´Ù¸é ¿¬°ü¹è¿¿¡´Â ¿ì¸®°¡ exam_memo¸¦ ¸¸µé¶§ ³Ö¾îÁÖ¾ú´ø...
no,name,memoµîÀÌ µé¾î°¡°ÚÁÒ...
ÇÏÁö¸¸ select count(*)·Î Ç߱⶧¹®¿¡ ¿ÀÇ ÃÑ°¹¼ö°¡ $total["count(*)"]¶ó´Â ¿¬°ü¹è¿ÀÇ º¯¼ö·Î µé¾î°©´Ï´Ù
ÀÏ´Ü ÀÌÇØ°¡ ¾È°¡½ÇÅÙµ¥......±Û ¸ñ·Ï ²¨³»¿Ã¶§ ´Ù½Ã Çѹø ´Ù·çµµ·Ï ÇÏ°Ú½À´Ï´Ù.
¾ÏÆ° À§ ¹®ÀåÀ¸·Î ¿ì¸®´Â ÀÔ·ÂµÈ ¸Þ¸ðÀÇ ÃÑ °¹¼ö¸¦ $total¿¡ Áý¾î ³Ö¾ú½À´Ï´Ù.
±×´ÙÀ½À¸·Î´Â ¾Æ±î »ç¿ëÇß´ø ½ÄÀ» ÀÌ¿ëÇÏ¿© $start¸¦ ±¸Çؾ߰ÚÁÒ.... º¸½ÃÁÒ~
<?
include"connect.php";//DB¿¡ Á¢¼Ó
$query="select count(*) from exam_memo"; //Äõ¸®¹®ÀúÀå
$total=mysql_fetch_array(mysql_query($query)); //Äõ¸®¹®ÀÔ·Â
$total=$total["count(*)"]; //°¹¼öÀúÀå
$page=10; //ÆäÀÌÁö´ç °¹¼ö
$pagesu=ceil($total/$page); //ÆäÀÌÁö¼ö¸¦ ±¸ÇÕ´Ï´Ù. °á°ú:4
$start=($page*$pagenum); //°¡Á®¿Ã ½ÃÀÛÀ§Ä¡¸¦ °áÁ¤ÇÕ´Ï´Ù.
?>
¿ä±â±îÁö ÀÔ´Ï´Ù.
°Ô½Ã¹°À» °¡Á®¿Ã Áغñ°¡ ´Ù µÈ°ÅÁÒ?
½ÃÀÛÀ§Ä¡($start)¿Í ÆäÀÌÁö´ç °¹¼ö($page)°¡ Á¤ÇØÁ³À¸´Ï ±×´ë·Î ¾Æ·¡¿Í °°ÀÌ Äõ¸®¹®À» ½áÁÖ¸é µË´Ï´Ù.
$query="select * from exam_memo order by no desc limit $start,$page";
$query¶ó´Â º¯¼ö¿¡ ´ÙÀ½°ú °°Àº Äõ¸®¹®À» ³Ö¾îÁØ°ÍÀÌÁÒ
select(°ñ¶ó¶ó)
*(¸ðµç°ÍÀ»)
from(¾îµð¿¡¼?)
exam_memo(exam_memoÅ×ÀÌºí¿¡¼)
order by(Á¤·ÄÀ»)
no(no·ÎÇؼ)
desc(³»¸²Â÷¼øÀ¸·Î)
limit(Á¦ÇÑÀ»)
$start(½ÃÀÛÀ§Ä¡ºÎÅÍ)
$page(ÆäÀÌÁö´ç°¹¼ö¸¸Å)
ÀÌÇØ°¡½ÃÁÒ?^^;
$query="select * from exam_memo order by no desc limit $start,$page";
$result=mysql_query($query,$connect);
$result¿¡ mysql_query()ÇÔ¼ö¸¦ »ç¿ëÇÑ °á°ú¹°À» Áý¾î ³Ö¾ú½À´Ï´Ù.
±×·¯´Ï±î selectÇÑ °á°ú°¡ $result¿¡ µé¾î°¡Àִ°ÅÁÒ....
ÀÌÁ¦ mysql_fetch_array()¸¦ »ç¿ëÇؼ ¿¬°ü¹è¿·Î ¸¸µé¸é µÇ°ÚÁÒ?
±×·±µ¥ ¾Æ±î¶û ´Ù¸¥Á¡ÀÌ ÀÖ½À´Ï´Ù. ¾Æ±î´Â ÇÑ°³ÀÇ ¿¸¸ ¹Þ¾ÆµéÀÌ´Â °ÍÀÌ°í...
À̹ø¿£ ¿ÀÌ ¸î°³ÀÎÁø ¸ô¶óµµ ÃÖ´ëÇÑ 10°³ÁÒ....
±×·¡¼ ÃÖ´ë 10¹ø±îÁö´Â ¹Ýº¹À» ÇØ¾ß ÇÕ´Ï´Ù.
¶§¹®¿¡ whileÀ̶ó´Â ¹Ýº¹¹®À» »ç¿ëÇϱâ·Î ÇÕ´Ï´Ù.....
$query="select * from exam_memo order by no desc limit $start,$page";
$result=mysql_query($query,$connect);
while($data=mysql_fetch_array($result))
{ }
@_@Á¡Á¡ º¹ÀâÇØÁöÁÒ?....
while($data=mysql_fetch_array($result)) À̺κп¡¼ ¼Ó ºÎºÐºÎÅÍ º¼±î¿ä
mysql_fetch_array($result) : °á°ú¹°À» ¿¬°ü¹è¿·Î ¸¸µì´Ï´Ù.
$data=mysql_fetch_array($result) : ¿¬°ü¹è¿À» $data¶ó´Â ¹è¿·Î Á¤ÀÇÇÕ´Ï´Ù.
while($data=mysql_fetch_array($result)) : while¹®À¸·Î ¹Ýº¹ÇÕ´Ï´Ù.
¿©±â¼ while¹®Àº ¹«ÇÑ·çÇÁ°¡ ¾Æ´Õ´Ï´Ù.
while¹®ÀÌ ·çÇÁµÇ¸é¼ ¿¬°ü¹è¿¿¡´Â °¡Á®¿Â µ¥ÀÌÅ͸¦ ÇÑÇ྿ ¸®ÅÏÇØÁÝ´Ï´Ù.
±×·¯´Ï±î ±ÛÀÌ 3°³°¡ ÀÖ¾úÀ¸¸é.....while¹®ÀÌ Ã³À½ µ¹¶§¿¡´Â 1¹ø±Û¿¡ ´ëÇÑ ¿¬°ü¹è¿ $data¸¦ º¸³»ÁÖ°í
µÎ¹ø° µ¹¶§´Â 2¹ø±Û¿¡ ´ëÇÑ ¿¬°ü¹è¿ $data¸¦ º¸³»ÁÖ°í....¼¼¹ø°¿¡´Â 3¹ø±Û.....
ÀÌ·¸°Ô µ¹¾Æ°¡°ÚÁÒ....
for¹®À» ¾µ¼ö Àִµ¥µµ whileÀ» »ç¿ëÇÑ°ÍÀº.....whileÀº Á¾·áÁöÁ¡À» Á¤ÇØ ÁÖÁö ¾Ê¾Æµµ
ÀÚµ¿À¸·Î ¸ðµç ÇàÀ» ¸®ÅÏÇÏ°í ³ª¸é Á¾·áµÇ±â ¶§¹®ÀÔ´Ï´Ù.
±×·¡¼ ¾Æ±îÀÇ °æ¿ì¶ó¸é 3Çà±îÁö ¸®ÅÏÇÏ°í Á¾·áµÇ°ÚÁÒ......
ÀÚ....ÀÌÇØ ¾ÈµÇ½ÃÁÒ-_-? (¿Ü¿ì¼¼¿ä....;;;)
<?
include"connect.php";//DB¿¡ Á¢¼Ó
$query="select count(*) from exam_memo"; //Äõ¸®¹®ÀúÀå
$total=mysql_fetch_array(mysql_query($query)); //Äõ¸®¹®ÀÔ·Â
$total=$total["count(*)"]; //°¹¼öÀúÀå
$page=10; //ÆäÀÌÁö´ç °¹¼ö
$pagesu=ceil($total/$page); //ÆäÀÌÁö¼ö¸¦ ±¸ÇÕ´Ï´Ù. °á°ú:4
$start=($page*$pagenum); //°¡Á®¿Ã ½ÃÀÛÀ§Ä¡¸¦ °áÁ¤ÇÕ´Ï´Ù.
$query="select * from exam_memo order by no desc limit $start,$page"; //²¨³»¿Ã Äõ¸®¹®
$result=mysql_query($query,$connect); //mysql¿¡ ¿äû
while($data=mysql_fetch_array($result)) //°á°ú¸¦ ²¨³»¿È
{ }
?>
À̺κР±îÁö µÇ¾ú½À´Ï´Ù.
±×·³ ÀÌÁ¦ { } ¿¡ Ãâ·Â¹®À» °£´ÜÇÏ°Ô ³Ö¾îº¼±î¿ä?
echo "$data[memo] <br>";
ÀÌ·± ¹®ÀåÀ» ³Ö¾îº¸ÁÒ....
$data¶ó´Â ¿¬°ü¹è¿¿¡¼ $data[memo]¶ó´Â °ÍÀº exam_memoÀÇ memo¶ó´Â Ç׸ñÀ» ²¨³»¿Â´Ù´Â °ÍÀÔ´Ï´Ù.
¿¹¸¦µé¾î ±ÛÀÌ ¾Æ·¡¿Í °°ÀÌ ÀԷµǾî ÀÖ´Ù°í Çغ¼±î¿ä...
[exam_memoÅ×À̺í]
no name memo
-- ---- ---------
01 test Å×½ºÆ®
02 navy ¿òÇÏÇÏ
03 babo ¹Ùº¸
04 navy ¿ìÇìÇì
ÀÌ·¸°Ô 4°³ÀÇ ±ÛÀÌ ÀÖ½À´Ï´Ù. -_-a;;;
À§ÀÇ echo¹®À» ¹Ýº¹¹®¿¡ ³Ö¾î¼ ½ÇÇàÀ» Çϸé......
ÇàÀÌ 4°³´Ï±î 4°³ ¸ðµÎ Ãâ·ÂÇÕ´Ï´Ù. limit¿¡¼ ²¨³»¿Ã°¹¼ö($page)°¡ 10À¸·Î µÇ¾îÀÖÁö¸¸...
10º¸´Ù ÀÛÀº 4°³°¡ ÀÖÀ¸¹Ç·Î 4°³ ¸ðµÎ ²¨³»¿É´Ï´Ù.....(14°³¶ó¸é 10°³¸¸ ²¨³»¿À°ÚÁÒ?)
°á°ú´Â ¾Æ·¡¿Í °°ÀÌ ³ª¿Ã°Ì´Ï´Ù.
¿ìÇìÇì
¹Ùº¸
¿òÇÏÇÏ
Å×½ºÆ®
¿ª¼øÀ¸·Î ³ª¿ÔÁÒ?....order by no desc Áï, noÀÇ ³»¸²Â÷¼øÀ̴ϱî...4,3,2,1¼øÀ¸·Î ³ª¿Â°ÅÁÒ
$data[memo]¸¦ Ãâ·ÂÇѰŴϱî....memoºÎºÐ¸¸ Ãâ·ÂµÇ¾ú½À´Ï´Ù.
Á» ´«Ä¡ºü¸£½ÅºÐµéÀº Áö±Ý ÀÌ ¿¹Á¦·Î ´ëÃæ °¨À» ÀâÀ¸¼ÌÀ»°Í °°½À´Ï´Ù....
ÀÚ ±×·³~ Á»´õ Á¦´ë·Î Çѹø ¸¸µé¾î º¼±î¿ä?...
Å×À̺íÀ» ±¸¼ºÇØ º¾½Ã´Ù...
<table border=1>
<tr><td>¹øÈ£</td><td>À̸§</td><td>¸Þ¸ð</td><td>½Ã°£</td></tr>
</table>
À§¿Í °°ÀÌ °¢ Ç׸ñÀ» ¼¿·Î ¸¸µé¾î ÇÑÇà¿¡ 4°³ÀÇ ¿À» »ý¼ºÇß½À´Ï´Ù.
¹øÈ£ À̸§ ¸Þ¸ð ½Ã°£
---- ---- ---- -----
ÀÌ·¸°Ô ³ª¿À´Â°Å°ÚÁÒ?
±×·³ DB¿¡¼ ²¨³»¿À´Â echo¹®À» ¾î¶»°Ô ÇØ¾ß ÇÒ±î¿ä?
echo "<tr><td>¹øÈ£</td><td>À̸§</td><td>¸Þ¸ð</td><td>½Ã°£</td></tr>";
ÀÌ·¸°Ô Çؼ µ¹·ÁÁÖ¸é µÇ°ÚÁÒ...¹°·Ð ¾È¿¡ µé¾î°¡´Â Ç׸ñµéÀº °¢ º¯¼ö·Î ä¿öÁà¾ß ÇÕ´Ï´Ù.
echo "<tr><td>$data[no]</td><td>$data[name]</td><td>$data[memo]</td><td>$data[date]</td></tr>";
ÀÌ·¸°Ô ÇØÁÖ¸é µÇ°ÚÁÒ....
¹øÈ£¿¡ $data[no]
À̸§¿¡ $data[name]
¸Þ¸ð¿¡ $data[memo]
½Ã°£¿¡ $data[date]
¶ó°í ³Ö¾îÁá½À´Ï´Ù.........
±×·±µ¥ ½Ã°£Àº ¿ì¸®°¡ DB¿¡ ³ÖÀ»¶§ À¯´Ð½º ŸÀÓ½ºÅÆÇÁ·Î ³Ö¾îµ×ÁÒ...
±×·¡¼ ¾Ë¾Æº¸±â ½±°Ô °¡°øÇØ ÁÖ¾î¾ß ÇÕ´Ï´Ù.
(³â-¿ù-ÀÏ)·Î¸¸ °¡°øÇØ º¾½Ã´Ù...
$data[date]=date('y-m-d',$data[date]);
date()ÇÔ¼ö¸¦ »ç¿ëÇؼ $data[date]¸¦ y-m-dÇü½ÄÀ¸·Î º¯°æÇÏ¿´½À´Ï´Ù.
±×·³ ÀÌÁ¦¼Ò½º¸¦ Á¤¸®ÇØ º¼±î¿ä;;
<?
include"connect.php";//DB¿¡ Á¢¼Ó
$query="select count(*) from exam_memo"; //Äõ¸®¹®ÀúÀå
$total=mysql_fetch_array(mysql_query($query)); //Äõ¸®¹®ÀÔ·Â
$total=$total["count(*)"]; //°¹¼öÀúÀå
$page=10; //ÆäÀÌÁö´ç °¹¼ö
$pagesu=ceil($total/$page); //ÆäÀÌÁö¼ö¸¦ ±¸ÇÕ´Ï´Ù. °á°ú:4
$start=($page*$pagenum); //°¡Á®¿Ã ½ÃÀÛÀ§Ä¡¸¦ °áÁ¤ÇÕ´Ï´Ù.
echo"
<table border=1>
<tr><td>¹øÈ£</td><td>À̸§</td><td>¸Þ¸ð</td><td>½Ã°£</td></tr>
"; //Å×À̺í½ÃÀÛ
$query="select * from exam_memo order by no desc limit $start,$page"; //²¨³»¿Ã Äõ¸®¹®
$result=mysql_query($query,$connect); //mysql¿¡ ¿äû
while($data=mysql_fetch_array($result)) //°á°ú¸¦ ²¨³»¿È
{
$data[date]=date('y-m-d',$data[date]);//½Ã°£°¡°ø
echo "<tr><td>$data[no]</td><td>$data[name]</td><td>$data[memo]</td><td>$data[date]</td></tr>";//²¨³»¿Â°ÍÃâ·Â
}
echo"</table>";//Å×ÀÌºí³¡
?>
¿ì¸®°¡ write.php¶ó´Â ÆÄÀÏÀ» ¸¸µé¶§.....
DB¿¡ ³Ö±âÀü¿¡ name°ú memo¿¡ addslashes()¶ó´Â ÇÔ¼ö¸¦ Àû¿ëÇØÁá´ø °ÍÀÌ ±â¾ï³ª½Ç°Ì´Ï´Ù.
Ư¼ö¹®ÀÚ¿¡ ¸¦ ºÙ¿©¼ DB¿¡ ³Ö¾ú¾úÁÒ......
ÀÌÁ¦ ²¨³»¿Ã¶§´Â ¸¦ Á¦°ÅÇØ¾ß °ÚÁÒ?^^
²¨³»¿Ã¶§´Â ¹Ý´ë·Î stripslashes()¶ó´Â ÇÔ¼ö¸¦ »ç¿ëÇØ ÁÝ´Ï´Ù.
ÀÌÁ¦ while¹® ¼Ó {}¿¡¸¸ º¸µµ·Ï ÇÏÁÒ;;
{
$data[date]=date('y-m-d',$data[date]);//½Ã°£°¡°ø
echo "<tr><td>$data[no]</td><td>$data[name]</td><td>$data[memo]</td><td>$data[date]</td></tr>";//²¨³»¿Â°ÍÃâ·Â
}
ÀÚ ¿©±â¿¡ stripslashes()ÇÔ¼ö¸¦ »ç¿ëÇØ ÁÙ±î¿ä~
{
$data[date]=date('y-m-d',$data[date]);//½Ã°£°¡°ø
$data[name]=stripslashes($data[name]);//À̸§¿¡¼ Á¦°Å
$data[memo]=stripslashes($data[memo]);//¸Þ¸ð¿¡¼ Á¦°Å
echo "<tr><td>$data[no]</td><td>$data[name]</td><td>$data[memo]</td><td>$data[date]</td></tr>";//²¨³»¿Â°ÍÃâ·Â
}
ÀÌ·¸°Ô ÇØÁÖ¸é ÀÔ·ÂÇÒ¶§ "³ª 'µîÀ» »ç¿ëÇß´õ¶óµµ ±×´ë·Î ÀÌ»ó ¾øÀÌ ²¨³»¿Ã¼ö ÀÖ°Ô µË´Ï´Ù.
¾Æ·¡ Àüü ¼Ò½º¸¦ Çѹø´õ º¸¿©µå¸®°Ú½À´Ï´Ù.
<?
include"connect.php";//DB¿¡ Á¢¼Ó
$query="select count(*) from exam_memo"; //Äõ¸®¹®ÀúÀå
$total=mysql_fetch_array(mysql_query($query)); //Äõ¸®¹®ÀÔ·Â
$total=$total["count(*)"]; //°¹¼öÀúÀå
$page=10; //ÆäÀÌÁö´ç °¹¼ö
$pagesu=ceil($total/$page); //ÆäÀÌÁö¼ö¸¦ ±¸ÇÕ´Ï´Ù. °á°ú:4
$start=($page*$pagenum)+1; //°¡Á®¿Ã ½ÃÀÛÀ§Ä¡¸¦ °áÁ¤ÇÕ´Ï´Ù.
echo"
<table border=1>
<tr><td>¹øÈ£</td><td>À̸§</td><td>¸Þ¸ð</td><td>½Ã°£</td></tr>
"; //Å×À̺í½ÃÀÛ
$query="select * from exam_memo order by no desc limit $start,$page"; //²¨³»¿Ã Äõ¸®¹®
$result=mysql_query($query,$connect); //mysql¿¡ ¿äû
while($data=mysql_fetch_array($result)) //°á°ú¸¦ ²¨³»¿È
{
$data[date]=date('y-m-d',$data[date]);//½Ã°£°¡°ø
$data[name]=stripslashes($data[name]);//À̸§¿¡¼ Á¦°Å
$data[memo]=stripslashes($data[memo]);//¸Þ¸ð¿¡¼ Á¦°Å
echo "<tr><td>$data[no]</td><td>$data[name]</td><td>$data[memo]</td><td>$data[date]</td></tr>";//²¨³»¿Â°ÍÃâ·Â
}
echo"</table>";//Å×ÀÌºí³¡
?>
À§ ¼Ò½º¸¦ list.phpÀÇ formÅÂ±× ¹Ø ºÎºÐÀ̳ª ÀºÎºÐ¿¡ ÆíÇϽŴë·Î ³Ö¾îÁÖ½Ã¸é µË´Ï´Ù.
Àü ¹Ø¿¡ ³Ö°Ú½À´Ï´Ù.
>>> list.php¼Ò½º
<form method=post action=write.php>
À̸§ <input type=text name=name size=10 maxlength=10>
¸Þ¸ð <input type=text name=memo size=30 maxlength=50>
<input type=submit value=ÀÔ·Â>
</form>
<?
include"connect.php";//DB¿¡ Á¢¼Ó
$query="select count(*) from exam_memo"; //Äõ¸®¹®ÀúÀå
$total=mysql_fetch_array(mysql_query($query)); //Äõ¸®¹®ÀÔ·Â
$total=$total["count(*)"]; //°¹¼öÀúÀå
$page=10; //ÆäÀÌÁö´ç °¹¼ö
$pagesu=ceil($total/$page); //ÆäÀÌÁö¼ö¸¦ ±¸ÇÕ´Ï´Ù. °á°ú:4
$start=($page*$pagenum); //°¡Á®¿Ã ½ÃÀÛÀ§Ä¡¸¦ °áÁ¤ÇÕ´Ï´Ù.
echo"
<table border=1>
<tr><td>¹øÈ£</td><td>À̸§</td><td>¸Þ¸ð</td><td>½Ã°£</td></tr>
"; //Å×À̺í½ÃÀÛ
$query="select * from exam_memo order by no desc limit $start,$page"; //²¨³»¿Ã Äõ¸®¹®
$result=mysql_query($query,$connect); //mysql¿¡ ¿äû
while($data=mysql_fetch_array($result)) //°á°ú¸¦ ²¨³»¿È
{
$data[date]=date('y-m-d',$data[date]);//½Ã°£°¡°ø
$data[name]=stripslashes($data[name]);//À̸§¿¡¼ Á¦°Å
$data[memo]=stripslashes($data[memo]);//¸Þ¸ð¿¡¼ Á¦°Å
echo "<tr><td>$data[no]</td><td>$data[name]</td><td>$data[memo]</td><td>$data[date]</td></tr>";//²¨³»¿Â°ÍÃâ·Â
}
echo"</table>";//Å×ÀÌºí³¡
?>
>>> list.php¼Ò½º³¡
ÀÚ À̼ҽº¸¦ ½ÇÇàÇϽðí.......
±ÛÀ» ¸¶±¸ÀâÀÌ·Î ³Ö¾îÁÝ´Ï´Ù......
¸¹ÀÌ ³ÖÀ»¼ö·Ï ÁÁ°ÚÁÒ~~~;;;
̵̧ : 340
̵̧
¸ñ·Ï