Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ob_start();
- session_start(); // start the session
- require_once "dbconfig.php"; // include the database information
- $to = "jperson19468@gmail.com";
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Test All Resources Page</title>
- <style>
- * {
- margin: 0;
- padding: 0;
- }
- .grid {
- display: grid;
- grid-template-rows: 45px 45px 45px;
- /* grid-template-columns: 165px 165px 165px; */
- grid-template-columns: repeat(3, 1fr);
- grid-gap: 10px;
- grid-column-gap: 5px;
- grid-row-gap: 10px;
- grid-auto-rows: 45px;
- }
- .grid {
- border: 2px solid #ff1aff;
- border-radius: 5px;
- background-color: #33cc33;
- width: 100%;
- }
- .the_color1 {
- border: 2px solid #ffa94d;
- border-radius: 5px;
- background-color: #ffd8a8;
- padding-top: 6px;
- padding-left: 5px;
- margin-top: 5px;
- margin-bottom: 5px;
- color: #ff0000;
- }
- .the_color2 {
- border: 2px solid #ffa94d;
- border-radius: 5px;
- background-color: #ffff00;
- padding-top: 1px;
- padding-left: 5px;
- margin-bottom: 20px;
- color: #000066;
- }
- .no_color {
- border: 2px solid #33cc33;
- border-radius: 5px;
- background-color: #33cc33;
- padding-top: 1px;
- margin-bottom: 20px;
- color: #33cc33;
- }
- </style>
- </head>
- <body>
- <?php
- $querystring = "select category_id
- from all_resources
- group by category_id
- limit 3";
- $result1 = mysqli_query($conn,$querystring);
- $v_error_message = "Something went wrong getting the categories all resources.";
- the_sql_error_routine($result1,$v_error_message,$conn);
- $rowcount1 = mysqli_num_rows($result1);
- $x=0;
- $a_category_name_array = array();
- while ($row = mysqli_fetch_array($result1,MYSQLI_ASSOC)){
- $v_category_id = $row['category_id'];
- $querystring = "select ucase(category_name) category_name
- from categories
- where category_id = '$v_category_id'";
- $result2 = mysqli_query($conn,$querystring);
- $v_error_message = "Something went wrong getting the categories.";
- the_sql_error_routine($result2,$v_error_message,$conn);
- $rowcount2 = mysqli_num_rows($result2);
- while ($row = mysqli_fetch_array($result2,MYSQLI_ASSOC)) {
- $v_category_name = $row['category_name'];
- $a_category_name_array[] = $v_category_name;
- }
- }
- sort($a_category_name_array);
- $v_total_values = count($a_category_name_array);
- $initi=0;
- $v_num_of_cols=3;
- print '<div class="grid">';
- for ($v_num_of_cols = $initi; $v_num_of_cols < $v_total_values; $v_num_of_cols++) {
- print '<div class="the_color1">';
- print "$a_category_name_array[$v_num_of_cols]";
- print '</div>'; // End the_color1 -->
- }
- $initi=0;
- $v_num_of_cols=3;
- for ($v_num_of_cols = $initi; $v_num_of_cols < $v_total_values; $v_num_of_cols++) {
- create_detail_routine($a_category_name_array[$v_num_of_cols], $conn, $v_num_of_cols);
- }
- print '</div>'; // End Grid -->
- function create_detail_routine($pa_category_name_array, $p_conn, $p_num_of_cols){
- // for ($j = $p_start; $j <= $p_end; $j++ ){
- $querystring = "select websiteaddress
- from categories cat, all_resources allr
- where cat.category_id = allr.category_id
- and cat.category_name = '$pa_category_name_array' ";
- $result3 = mysqli_query($p_conn,$querystring);
- $v_error_message = "Something went wrong getting the webesite name or website address.";
- the_sql_error_routine($result3,$v_error_message,$p_conn);
- $columncount = mysqli_num_rows($result3);
- // echo 'p_num_of_cols '.$p_num_of_cols;
- print '<div>';
- while ($row = mysqli_fetch_array($result3,MYSQLI_ASSOC)) {
- $v_websiteaddress = $row['websiteaddress'];
- if ( $p_num_of_cols == 0 ) {
- print '<div class="the_color2">';
- print 'WebSite Name '.$v_websiteaddress;
- print '</div>'; // End the_color2 -->
- print '<div class="no_color"></div>';
- print '<div class="no_color"></div>';
- }
- if ( $p_num_of_cols == 1 ) {
- print '<div class="no_color"></div>';
- print '<div class="the_color2">';
- print 'WebSite Name '.$v_websiteaddress;
- print '</div>'; // End the_color2 -->
- print '<div class="no_color"></div>';
- }
- if ( $p_num_of_cols == 2 ) {
- print '<div class="no_color"></div>';
- print '<div class="no_color"></div>';
- print '<div class="the_color2">';
- print 'WebSite Name '.$v_websiteaddress;
- print '</div>'; // End the_color2 -->
- }
- }
- print '</div>';
- } /* End the create detail routine */
- function the_sql_error_routine($p_result,$p_error_message,$p_conn){
- $to = "jperson19468@gmail.com";
- if (!$p_result){
- echo "$p_error_message. MySQL said: ".mysqli_error($p_conn);
- $the_error = mysqli_error($p_conn);
- mail($to, "Error in lineup6.php",$the_error);
- }
- } /* End the sql error routine */
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement