Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.15 KB | None | 0 0
  1.  
  2. <form action="WordPress/calculation.php">
  3.     <input type="text" name="year">
  4.     <select name="teacher">
  5.         <option value='0' default>Все</option>
  6.         <?php
  7.             $teachers = $wpdb->get_results("SELECT * FROM wp_users;");
  8.             foreach ($teachers as $teacher) {
  9.                 echo "<option value='".$teacher->id."'>".$teacher->last_name."</option>";
  10.             }
  11.         ?>
  12.     </select>
  13.     <submit value='Посчитать'>
  14. </form>
  15.  
  16.  
  17. calculation.php
  18. <table>
  19. <?php
  20.     $year = htmlspecialchars(trim($_POST["year"]);
  21.     $teacher = htmlspecialchars(trim($_POST["teacher"]);
  22.     if ($teacher == "") {
  23.         $teachers = $wpdb->get_results("SELECT * FROM wp_users;");
  24.         foreach ($teachers as $teacher) {
  25.             $articles = $wpdb->get_results("SELECT * FROM wp_articles_for_pps ".
  26.                     "WHERE id_prepod='$teacher' AND year='$year';");
  27.             $value = 0;
  28.             foreach ($articles as $article) {
  29.                 $indicator = $wpdb->get_row("SELECT * FROM wp_indicators ".
  30.                     "WHERE id_index='$article->id_index';");
  31.                 $value = $value + $indicator->coefficient*$article->amount;
  32.             }
  33.             echo "<tr>"
  34.             echo "<td>$teacher->last_name</td>";
  35.             echo "<td>$value</td>";
  36.             echo "</tr>"
  37.         }  
  38.     } else {
  39.  
  40.     }
  41. ?>
  42. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement