Advertisement
xakepabg

HTML Table / PHP Loop 2

Jun 14th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.03 KB | None | 0 0
  1. <?php
  2.  
  3. function get_films() {
  4.     $conn = mysqli_connect('localhost', 'root', 'passwd', 'kino');
  5.     if (!$conn) {
  6.         echo mysqli_error($conn);
  7.     }
  8.  
  9.     mysqli_set_charset($conn, 'utf8');
  10.  
  11.     $getAllFilms = mysqli_query($conn, "SELECT
  12. films.film_id,films.film_name,films.film_price,
  13. date_proj.f_id,date_proj.time_proj,date_proj.dates_proj
  14. FROM films LEFT JOIN date_proj ON date_proj.f_id=films.film_id WHERE date_proj.f_id = films.film_id GROUP BY date_proj.f_id");
  15.  
  16.     $allFilms = array();
  17.  
  18.     while ($filmObject = mysqli_fetch_object($getAllFilms)) {
  19.         $allFilms[] = $filmObject;
  20.     }
  21.     return $allFilms;
  22. }
  23.  
  24. function get_tables() {
  25.  
  26.     $tbl_str = '<table class="table table-striped table-dark">';
  27.     $fullInfoFilms = get_films();
  28.     foreach ($fullInfoFilms as $rowFilms) {
  29.         $tbl_str .= '<tr>';
  30.         $tbl_str .= '<th scope="col"></th>';
  31.         $tbl_str .= '<th scope="col"></th><th scope="col">' . $rowFilms->film_name . '</th><th scope="col">' . $rowFilms->film_price . '</th>
  32.            <th scope="col">' . $rowFilms->time_proj . '</th><th scope="col">' . $rowFilms->dates_proj . '</th>';
  33.         $tbl_str .= '</tr>';
  34.     }
  35.     $tbl_str .= '</table>';
  36.     return $tbl_str;
  37. }
  38. ?>
  39.  
  40. <!doctype html>
  41.  
  42. <html lang="bg">
  43.     <head>
  44.         <meta charset="utf-8">
  45.  
  46.         <title>Кино - Royal Мездра</title>
  47.         <meta name="description" content="кино,филми,films,kino">
  48.         <meta name="autdor" content="Toshko Tan`ew">
  49.         <link href="css/bootstrap.css" rel="stylesheet" type="text/css"/>
  50.         <script src="js/bootstrap.js" type="text/javascript"></script>
  51.         <!--[if lt IE 9]>
  52.           <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
  53.         <![endif]-->
  54.         <style type="text/css">
  55.             .price {
  56.                 line-height: 5px;
  57.                 min-height: 5px;
  58.                 height: 5px;
  59.             }
  60.  
  61.             .fixed{
  62.                 width: 50%;
  63.             }
  64.         </style>
  65.     </head>
  66.     <body>
  67. <?php
  68. echo get_tables();
  69. ?>
  70.     </body>
  71. </html>
  72.  
  73.         <?php
  74.         /*
  75.           header('Content-Type: text/html; charset=UTF-8');
  76.           $weekModifier = 0;
  77.  
  78.           $locale = 'bg_BG.utf8';
  79.           setlocale(LC_ALL, $locale);
  80.  
  81.           $date = new DateTime();
  82.  
  83.           if($date->format('N') !== 1) {
  84.           $date->sub(new DateInterval('P'. $date->format('N') . 'D'));
  85.           }
  86.  
  87.           $interval = new DateInterval('P'.abs($weekModifier).'W');
  88.  
  89.           if($weekModifier > 0) {
  90.           $date->add($interval);
  91.           } else {
  92.           $date->sub($interval);
  93.           }
  94.  
  95.           for($i = 1; $i <= 7; $i++) {
  96.           echo $date->add(new DateInterval('P1D'))->format('l d-m-Y') . "<br>\n";
  97.           }
  98.          *
  99.          *
  100.          *
  101.          * 'SELECT films.film_id,films.film_name,films.film_price,
  102.           date_proj.f_id,date_proj.time_proj,date_proj.dates_proj
  103.           FROM films RIGHT JOIN date_proj'
  104.          */
  105.         ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement