Advertisement
chack1172

Untitled

Aug 28th, 2017
645
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.15 KB | None | 0 0
  1. <?php
  2.    ob_start();
  3.    session_start(); // start the session
  4.    require_once "dbconfig.php"; // include the database information
  5.    $to               = "jperson19468@gmail.com";
  6.  
  7. ?>
  8. <!DOCTYPE html>
  9. <html>
  10. <head>
  11. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  12. <title>Test All Resources Page</title>
  13.  
  14. <style>
  15. * {
  16.    margin:  0;
  17.    padding: 0;
  18. }
  19.  
  20. .grid {
  21.   display: grid;
  22.   grid-template-rows: 45px 45px 45px;
  23. /*  grid-template-columns: 165px 165px 165px; */
  24.   grid-template-columns: repeat(3, 1fr);
  25.   grid-gap: 10px;
  26.   grid-column-gap: 5px;
  27.   grid-row-gap: 10px;
  28.   grid-auto-rows: 45px;
  29. }
  30.  
  31. .grid {
  32.     border: 2px solid #ff1aff;
  33.     border-radius: 5px;
  34.     background-color: #33cc33;
  35.     width: 100%;
  36. }
  37.  
  38. .the_color1 {
  39.     border: 2px solid #ffa94d;
  40.     border-radius: 5px;
  41.     background-color: #ffd8a8;
  42.     padding-top: 6px;
  43.     padding-left: 5px;
  44.     margin-top: 5px;
  45.     margin-bottom: 5px;
  46.     color: #ff0000;
  47. }
  48.  
  49. .the_color2 {
  50.     border: 2px solid #ffa94d;
  51.     border-radius: 5px;
  52.     background-color: #ffff00;
  53.     padding-top: 1px;
  54.     padding-left: 5px;
  55.     margin-bottom: 20px;
  56.     color: #000066;
  57. }
  58.  
  59. .no_color {
  60.     border: 2px solid #33cc33;
  61.     border-radius: 5px;
  62.     background-color: #33cc33;
  63.     padding-top: 1px;
  64.     margin-bottom: 20px;
  65.     color: #33cc33;
  66. }
  67. </style>
  68.  
  69. </head>
  70. <body>
  71.  
  72.                 <?php
  73.                 $querystring = "select category_id
  74.                                       from all_resources
  75.                                       group by category_id
  76.                                       limit 3";
  77.  
  78.                 $result1 = mysqli_query($conn,$querystring);
  79.  
  80.                 $v_error_message = "Something went wrong getting the categories all resources.";
  81.                 the_sql_error_routine($result1,$v_error_message,$conn);
  82.  
  83.                 $rowcount1 = mysqli_num_rows($result1);
  84.  
  85.                 $x=0;
  86.                 $a_category_name_array   = array();
  87.  
  88.                 while ($row = mysqli_fetch_array($result1,MYSQLI_ASSOC)){
  89.                     $v_category_id   = $row['category_id'];
  90.  
  91.                     $querystring = "select ucase(category_name) category_name
  92.                                           from categories
  93.                                           where category_id = '$v_category_id'";
  94.  
  95.                     $result2 = mysqli_query($conn,$querystring);
  96.  
  97.                     $v_error_message = "Something went wrong getting the categories.";
  98.                     the_sql_error_routine($result2,$v_error_message,$conn);
  99.  
  100.                     $rowcount2 = mysqli_num_rows($result2);
  101.  
  102.                     while ($row = mysqli_fetch_array($result2,MYSQLI_ASSOC)) {
  103.                         $v_category_name            = $row['category_name'];
  104.                         $a_category_name_array[]    = $v_category_name;
  105.                     }
  106.                 }
  107.  
  108.                 sort($a_category_name_array);
  109.                 $v_total_values = count($a_category_name_array);
  110.                 $initi=0;
  111.                 $v_num_of_cols=3;
  112.  
  113.                 print '<div class="grid">';
  114.                 for ($v_num_of_cols = $initi; $v_num_of_cols < $v_total_values; $v_num_of_cols++) {
  115.                      print '<div class="the_color1">';
  116.                         print "$a_category_name_array[$v_num_of_cols]";
  117.                      print '</div>'; //  End the_color1 -->
  118.                 }
  119.  
  120.                 $initi=0;
  121.                 $v_num_of_cols=3;
  122.                 for ($v_num_of_cols = $initi; $v_num_of_cols < $v_total_values; $v_num_of_cols++) {
  123.                      create_detail_routine($a_category_name_array[$v_num_of_cols], $conn, $v_num_of_cols);
  124.                 }
  125.  
  126.                 print '</div>';  // End Grid -->
  127.  
  128. function create_detail_routine($pa_category_name_array, $p_conn, $p_num_of_cols){
  129.  
  130.  //   for ($j = $p_start; $j <= $p_end; $j++ ){
  131.         $querystring = "select websiteaddress
  132.                               from categories cat, all_resources allr
  133.                               where cat.category_id      = allr.category_id
  134.                                and  cat.category_name    = '$pa_category_name_array' ";
  135.                      
  136.         $result3 = mysqli_query($p_conn,$querystring);
  137.                      
  138.         $v_error_message = "Something went wrong getting the webesite name or website address.";
  139.         the_sql_error_routine($result3,$v_error_message,$p_conn);
  140.  
  141.         $columncount    = mysqli_num_rows($result3);
  142.  
  143.  
  144.    //     echo 'p_num_of_cols '.$p_num_of_cols;
  145.         print '<div>';
  146.         while ($row = mysqli_fetch_array($result3,MYSQLI_ASSOC)) {
  147.                $v_websiteaddress  = $row['websiteaddress'];
  148.  
  149.                if ( $p_num_of_cols == 0 ) {
  150.                   print '<div class="the_color2">';
  151.                      print 'WebSite Name '.$v_websiteaddress;
  152.                   print '</div>'; // End the_color2  -->
  153.                   print '<div class="no_color"></div>';
  154.                   print '<div class="no_color"></div>';
  155.                }
  156.  
  157.                if ( $p_num_of_cols == 1 ) {
  158.                   print '<div class="no_color"></div>';
  159.                   print '<div class="the_color2">';
  160.                      print 'WebSite Name '.$v_websiteaddress;
  161.                   print '</div>'; // End the_color2  -->
  162.                   print '<div class="no_color"></div>';
  163.                }
  164.  
  165.                if ( $p_num_of_cols == 2 ) {
  166.                   print '<div class="no_color"></div>';
  167.                   print '<div class="no_color"></div>';
  168.                   print '<div class="the_color2">';
  169.                      print 'WebSite Name '.$v_websiteaddress;
  170.                   print '</div>'; // End the_color2  -->
  171.  
  172.                }
  173.  
  174.          }
  175.         print '</div>';
  176.  
  177. }   /* End the create detail routine */
  178.  
  179. function the_sql_error_routine($p_result,$p_error_message,$p_conn){
  180.  
  181.     $to                = "jperson19468@gmail.com";
  182.     if (!$p_result){
  183.        echo "$p_error_message. MySQL said: ".mysqli_error($p_conn);
  184.        $the_error = mysqli_error($p_conn);
  185.        mail($to, "Error in lineup6.php",$the_error);
  186.     }
  187. } /* End the sql error routine */
  188.    
  189. ?>
  190. </body>
  191. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement