asimryu

20150925_php

Sep 24th, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.90 KB | None | 0 0
  1. <?php require("dbconn.php"); ?>
  2. <!doctype html>
  3. <html>
  4. <head>
  5. <meta charset="utf-8">
  6. <title>게시판프로그램</title>
  7. <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/start/jquery-ui.css">
  8. <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
  9. <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  10. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  11. <style>
  12.     #view { display: none; }
  13. </style>
  14. </head>
  15. <body>
  16.     <table id="list" class="table table-hover">
  17.  <tr>
  18.  <td>번호</td>
  19.  <td>제목</td>
  20.  <td>글쓴이</td>
  21.  <td>날짜</td>
  22.  </tr>  
  23.     <?php foreach($db->query('SELECT * FROM board') as $row) { ?>
  24.     <tr class="list-row" data-content="<?php echo $row['content'];?>">
  25.   <td class="list-idx"><?php echo $row['idx'];?></td>
  26.   <td class="list-title"><?php echo $row['title'];?></td>
  27.   <td class="list-writer"><?php echo $row['writer'];?></td>
  28.   <td class="list-wdate"><?php echo $row['wdate'];?></td>
  29.  </tr>  
  30.     <?php } ?>
  31.  </table>
  32.  <div id="view">
  33.     <table class="table">
  34.     <tr><td>제목</td><td id="view-title"></td></tr>
  35.     <tr><td>본문</td><td id="view-content"></td></tr>
  36.     <tr><td>글쓴이</td><td id="view-writer"></td></tr>
  37.     <tr><td>날짜</td><td id="view-wdate"></td></tr>
  38.   </table>
  39.  </div>
  40.  <script>
  41.         $(".list-row").click( function(){
  42.             var idx = $(this).children(".list-idx").html();
  43.             var title = $(this).children(".list-title").html();
  44.             var writer = $(this).children(".list-writer").html();
  45.             var wdate = $(this).children(".list-wdate").html();
  46.             var content = $(this).attr("data-content");
  47.             $("#view-title").html(title);
  48.             $("#view-writer").html(writer);
  49.             $("#view-wdate").html(wdate);
  50.             $("#view-content").html(content);
  51.             $("#view").dialog({
  52.                 title: title,
  53.                 width: 300,
  54.                 height: 300
  55.             });
  56.         } );
  57.     </script>
  58. </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment