Advertisement
Guest User

Untitled

a guest
May 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.61 KB | None | 0 0
  1. <?php /* Template Name: ScenesCustomPage */ ?>
  2. <?php
  3. /**
  4.  * The template for displaying pages
  5.  *
  6.  * This is the template that displays all pages by default.
  7.  * Please note that this is the WordPress construct of pages and that
  8.  * other "pages" on your WordPress site will use a different template.
  9.  *
  10.  * @package WordPress
  11.  * @subpackage Twenty_Sixteen
  12.  * @since Twenty Sixteen 1.0
  13.  */
  14.  
  15. get_header(); ?>
  16.  
  17. <div id="primary" class="content-area">
  18.     <main id="main" class="site-main" role="main">
  19.         <?php
  20.         // Start the loop.
  21.         while ( have_posts() ) : the_post();
  22.  
  23.             // Include the page content template.
  24.             get_template_part( 'template-parts/content', 'page' );
  25.  
  26.             // If comments are open or we have at least one comment, load up the comment template.
  27.             if ( comments_open() || get_comments_number() ) {
  28.                 comments_template();
  29.             }
  30.  
  31.             // End of the loop.
  32.         endwhile;
  33.         ?>
  34.        
  35.         <?php
  36.             global $wpdb;
  37.             if (isset($_POST['add_scenes'])) {
  38.                 $scenes_number = $wpdb->get_var( "SELECT COUNT(*) FROM scenes" );
  39.                 echo "scenes_number: ${scenes_number}";
  40.                
  41.                 $scenes = $wpdb->insert( "scenes", array (
  42.                     "idscene" => $scenes_number,
  43.                     "number" => $_POST["number"],
  44.                     "objects" => $_POST["object"],
  45.                     "characters" => $_POST["characters"],
  46.                     "typeplace" => $_POST["typeplace"],
  47.                     "modes" => $_POST["modes"],
  48.                     "status" => $_POST["status"],
  49.                
  50.                
  51.                 ));
  52.                 $wpdb->print_error();
  53.             }
  54.        
  55.         ?>
  56.        
  57.         &nbsp;
  58.         <?php
  59.             global $wpdb;
  60.             $scenes = $wpdb->get_results( "SELECT number, objects, characters, typeplace, modes, status FROM scenes" );
  61.             if ( $scenes )
  62.             {
  63.                 foreach ( $scenes as $sc )
  64.                 {
  65.                     echo "<p>One more character: number is {$sc->number}, modes is {$sc->modes} </p>"; 
  66.                 }          
  67.             }
  68.         ?>
  69.         <table border="1">
  70.             <tbody>
  71.                 <tr>
  72.                     <td>Номер </td>
  73.                     <td>Объкт</td>
  74.                     <td>Персонажи</td>
  75.                     <td>Интерьер/Натура</td>
  76.                     <td>Режим</td>
  77.                     <td>Статус</td>
  78.                    
  79.                
  80.                 </tr>
  81.                
  82.             </tbody>
  83.             <tbody>
  84.             <?php foreach ($scenes as $sc): ?>
  85.                 <tr>
  86.                     <td><?php echo $sc->number; ?></td>
  87.                     <td><?php echo $sc->objects; ?></td>
  88.                     <td><?php echo $sc->characters; ?></td>
  89.                     <td><?php echo $sc->typeplace; ?></td>
  90.                     <td><?php echo $sc->modes; ?></td>
  91.                     <td><?php echo $sc->status; ?></td>
  92.                 </tr>
  93.             <?php endforeach; ?>
  94.             </tbody>
  95.         </table>
  96.         <header><b>Добавление сцены</b></header>
  97.        
  98.         <form method="post" action="">
  99.             Номер
  100.             <input type="text" name="number" />
  101.             Объкт
  102.             <input type="text" name="objects" />
  103.             Персонажи
  104.             <input type="text" name="characters" />
  105.            
  106.            
  107.             Интерьер/Натура
  108.             <input name="typeplace" type="radio" value="Интерьер" /> Интерьер
  109.             <input name="typeplace" type="radio" value="Натура" /> Натура
  110.            
  111.            
  112.            
  113.             Режим
  114.             <input name="modes" type="radio" value="Утро" /> Утро
  115.             <input name="modes" type="radio" value="День" /> День
  116.             <input name="modes" type="radio" value="Вечер" /> Вечер
  117.             <input name="modes" type="radio" value="Ночь" /> Ночь
  118.            
  119.            
  120.        
  121.             Статус
  122.             <input name="status" type="radio" value="Снято" /> Снято
  123.             <input name="status" type="radio" value="Не снято" /> Не снято
  124.            
  125.        
  126.             <input type="submit" name="add_scenes" value=" Добавить сцену " />
  127.         </form>&nbsp;
  128.  
  129.        
  130.     </main><!-- .site-main -->
  131.  
  132.     <?php get_sidebar( 'content-bottom' ); ?>
  133.  
  134. </div><!-- .content-area -->
  135.  
  136. <?php get_sidebar(); ?>
  137. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement