Guest User

Untitled

a guest
May 27th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.00 KB | None | 0 0
  1. Файл index.php:
  2.  
  3. <!DOCTYPE html>
  4. <html>
  5. <head>
  6. <link rel="stylesheet" href="style.css">
  7. <script type="text/javascript"
  8. src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js">
  9. </script>
  10. <link href="https://fonts.googleapis.com/css?
  11. family=Lato:700i|Song+Myung" rel="stylesheet">
  12. <?php
  13. require "db.php";
  14. require_once "functions/functions.php";
  15. $blocks = getBlocks(3, $id);//по сути нам на данной странице оба
  16. аргумента не нужны, написано чтобы не было ошибки, нужно для другого
  17.  
  18. if(isset($_POST["add_skill_btn"])) {
  19. if(trim($_POST["skill_name"]) == '') {
  20. echo "Wrong skill";
  21. } else {
  22. $skill_name = htmlspecialchars($_POST["skill_name"]);
  23. $skill = R::dispense('skills');//фреймворк Red Bean php создаёт таблицу
  24. $skill->name = $_POST["skill_name"];
  25. R::store($skill);//фреймворк Red Bean php сохраняет таблицу
  26. }
  27. }
  28. ?>
  29. <script>
  30. $(document).ready(function () {
  31. $('#first').on('click', function() {
  32. $('#goals').hide();
  33. $('#skills').toggle(200);
  34. });
  35. $('#second').on('click', function() {
  36. $('#skills').hide();
  37. $('#goals').toggle(200);
  38. });
  39. });
  40. </script>
  41. </head>
  42. <body>
  43. <div id="aside">
  44. <div id="first">
  45. <h2 class="titles">Skills</h2>
  46. </div>
  47. <div id="second">
  48. <h2 class="titles">Goals</h2>
  49. </div>
  50. </div>
  51.  
  52. <div id="skills">
  53. <form method="post" name="skill_form">
  54. <button type="submit" id="add_skill_btn"
  55. name="add_skill_btn">ADDSKILL</button>
  56. <input type="text" id="add_skill_input" name="skill_name" placeholder="
  57. New skill?">
  58. </form>
  59.  
  60. <div id="kill_zone"><!--рабочая область-где все блоки со скиллами-->
  61.  
  62. <?php
  63. for ($i = 0; $i < count($blocks); $i++) {
  64.  
  65. echo '<a href="#">
  66. <div class="skill_block">
  67. <h2>'.$blocks[$i]["name"].'</h2>
  68. </div>
  69. </a>';
  70. }
  71. ?>
  72. </div>
  73.  
  74. </div>
  75.  
  76. <div id="goals">
  77. <div><h2>Here is another text</h2></div>
  78. </div>
  79.  
  80. </body>
  81. </html>
  82.  
  83. Файл style.css:
  84.  
  85. body {
  86. margin: 0px;
  87. background-color: #002338;
  88. }
  89.  
  90. a {
  91. text-decoration: none;
  92. }
  93.  
  94. #aside{
  95. height: 729px;
  96. width: 15%;
  97. float: left;
  98. background-color: rgba(18,18,18,0.92);
  99. }
  100.  
  101. #first {
  102. text-align: center;
  103. box-shadow: 0px 2px 16px 17px rgba(74,51,50,1);
  104. margin: 40px auto;
  105. height: 120px;
  106. width: 150px;
  107. background-color: #57110a;
  108. }
  109.  
  110. #second {
  111. text-align: center;
  112. box-shadow: 0px 2px 16px 17px rgba(96,99,24,1);
  113. margin: 100px auto;
  114. height: 120px;
  115. width: 150px;
  116. background-color: #57531c;
  117. }
  118.  
  119. .titles {
  120. padding-top: 45px;
  121. font-family: 'Ubuntu', sans-serif;
  122. }
  123.  
  124. #skills {
  125. width:85%;
  126. height: 729px;
  127. float: right;
  128. background-color: #002338;
  129. display: none;
  130. }
  131.  
  132. #goals {
  133. width:85%;
  134. height: 729px;
  135. float: right;
  136. background-color: #002338;
  137. display: none;
  138. }
  139.  
  140. #add_skill_btn {
  141. margin: 15px;
  142. float: right;
  143. width: 75px;
  144. height: 65px;
  145. border: 1px solid #868686;
  146. border-radius: 5px;
  147. background-color: #02acc8;
  148. box-shadow: inset 0px 0px 27px 10px rgba(50, 50, 50, 0.59);
  149. font-weight: 700;
  150. font-size: 1.2em;
  151. color: #303231;
  152. }
  153.  
  154. #add_skill_input {
  155. margin: 20px -5px;
  156. float: right;
  157. height: 50px;
  158. width: 150px;
  159. border: 1px solid #868686;
  160. border-radius: 5px;
  161. background-color: #02acc8;
  162. box-shadow: inset 0px 0px 27px 10px rgba(50, 50, 50, 0.59);
  163. font-size: 1.3em;
  164. font-weight: 800;
  165. letter-spacing: 2px;
  166. }
  167. input::-webkit-input-placeholder {
  168. color: #4f5150;
  169. }
  170.  
  171. #kill_zone {
  172. width: 85%;
  173. margin-left: 5%;
  174. margin-right: 5%;
  175. height: auto;
  176. margin-top: 150px;
  177. }
  178.  
  179. .skill_block {
  180. width: 216px;
  181. height: 170px;
  182. background-color: bisque;
  183. border: 10px solid #ADA7A7;
  184. border-radius: 15px;
  185. box-shadow: inset 0px 0px 25px 9px #ADA7A7;
  186. text-align: center;
  187. box-sizing: border-box;
  188. float: left;
  189. margin-left: 90px;
  190. margin-top: 50px;
  191. }
  192.  
  193. .skill_block h2 {
  194. font-weight: normal;
  195. font-size: 2em;
  196. font-family: 'Song Myung', serif;
  197. color: rgba(18,18,18,0.92);
  198. margin-top: 50px;
  199. }
  200.  
  201. Файл functions.php :
  202. <?php
  203. require_once "connect.php";
  204.  
  205. function getBlocks ($limit, $id) {
  206. global $mysqli;
  207. connectDB();
  208.  
  209. $result = $mysqli->query("SELECT * FROM `skills` ORDER BY `id` ASC");
  210. closeDB();
  211.  
  212. if(!$id)
  213. return resultToArray($result);
  214. else
  215. return $result->fetch_assoc();
  216. }
  217.  
  218. function resultToArray ($result) {
  219. $array = array();
  220. while (($row = $result->fetch_assoc()) != false)
  221. $array[] = $row;
  222. return $array;
  223. }
  224.  
  225. Файл db.php:
  226. <?php
  227. require "libs/rb-mysql.php";
  228. R::setup('mysql:host=localhost;dbname=General_project','root', '' );
Add Comment
Please, Sign In to add comment