php for문 예제

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  5. <title>title</title>
  6. <style type="text/css">
  7. html,body {width:800px; margin:0 auto; padding:0;}
  8. li {float:left; position:relative; width:380px; padding:0 0 10px 0; list-style:none;}
  9. li p {position:absolute; top:00px; right:40px; font-size:100px; text-align:right; font-style:italic; font-family:arial;}
  10. li img {width:365px; border:4px solid #aaa;}
  11. ul {margin:0 auto; padding:0; width:800px;}
  12. </style>
  13. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  14. <script type="text/javascript">
  15. $(document).ready(
  16.     function() {
  17.         $("li:nth-child(8n+1)").css("page-break-before", "always");  //8의 배수 + 1 번째 아이템을 반환, 다음페이지에 인쇄
  18.     });
  19. </script>
  20. </head>
  21. <body>
  22. <ul>
  23. <?php
  24.     for($index=1; $index<=500; $index=$index+1) { // "+1" 한줄에 보여지는 갯수
  25.         echo "<li><img src='img/01.jpg' /><p>" . sprintf('%03d', $index) . "</p></li>";
  26.     }
  27. ?>
  28. </ul>
  29. </body>
  30. </html>
  31. ==========================================================================
  32. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  33. <html>
  34. <head>
  35. <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  36. <title>title</title>
  37. <style type="text/css">
  38. html,body {width:800px; margin:0 auto; padding:0;}
  39. li {float:left; position:relative; width:100px; padding:0 0 10px 0; list-style:none;}
  40. li p {position:absolute; top:00px; right:40px; font-size:100px; text-align:right; font-style:italic; font-family:arial;}
  41. li img {}
  42. ul {margin:0 auto; padding:0; width:800px;}
  43. </style>
  44. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  45. <script type="text/javascript">
  46. /*
  47. $(document).ready(
  48.     function() {
  49.         $("li:nth-child(8n+1)").css("page-break-before", "always");  //8의 배수 + 1 번째 아이템을 반환, 다음페이지에 인쇄
  50.     });
  51. */
  52. </script>
  53. </head>
  54. <body>
  55. <ul>
  56. <?php
  57.     for($index=2001; $index<=2500; $index=$index+1) { // "+1" 한줄에 보여지는 갯수
  58.         echo "<li><img src='http://htmltutor.co.kr/new/zero/icon/private_name/" . sprintf('%01d', $index) . ".gif' /></li>"; //" . sprintf('%03d', $index) . "
  59.     }
  60. ?>
  61. </ul>
  62. </body>
  63. </html>
  64. 밖에
  65. <?for($index=1; $index<=9; $index=$index+1) { ?>
  66.     내용
  67. <? } ?>
  68. <?for($index=1; $index<=10; $index=$index+1) { ?>
  69.     <a href="#pageNum"><?=$index?></a>
  70. <? } ?>
  71. <?for($i=1; $i<=10; $i++){ ?>
  72.     <a href="#pageNum"><?=$i;?></a>
  73. <? } ?>
php for문 예제 php for문 예제 Reviewed by jieun on 오전 9:15 Rating: 5

댓글 없음:

Powered by Blogger.