Jump to content

Barand

Moderators
  • Posts

    24,420
  • Joined

  • Last visited

  • Days Won

    805

Posts posted by Barand

  1. 10 minutes ago, Jim R said:

    The code would be stagnant.  We know every year in basketball, teams in sectional 1-16 are 4A.  What we don't know is which class or sectional every team is in from year to year.  

    In which case you have in intermediate file to record, each season, which sectional a team is in

    image.thumb.png.4d670a82def84759b19629bf138ebffd.png

  2. 1 hour ago, Jim R said:

    So I have a Schools table that has a BSectionals column (B = basketball), and I'll eventually have a column for each sport.

    Adding columns for each sport is not the way to design database tables.

    From what you described above,

    • Each sport has several classes
    • Each class has several sectionals
    • Each sectional has several teams
    • Each school has several teams(sports)

    so your data should reflect this structure

    image.png.500089d1937a3c52866aad53cb93e002.png

  3. I think you should recheck your calculations

    +-------+----------+---------+----------+-------------------+-----------------+
    | recno | user     | v_score | reccount | last5             |  av5 = last5/5  |   my results      your results
    +-------+----------+---------+----------+-------------------+-----------------+
    |     3 | mina1111 |       2 |        1 | 2                 |                 |
    |     6 | mina1111 |       4 |        2 | 2 + 4             |                 |
    |     7 | mina1111 |       3 |        3 | 2 + 4 + 3         |                 |
    |     8 | mina1111 |       2 |        4 | 2 + 4 + 3 + 2     |                 |
    |     9 | mina1111 |       4 |        5 | 2 + 4 + 3 + 2 + 4 | 15/5 = 3.0      |    3.0000            4.0000
    |    10 | mina1111 |       5 |        6 | 4 + 3 + 2 + 4 + 5 | 18/5 = 3.6      |    3.6000            4.5000
    |    11 | mina1111 |       0 |        7 | 3 + 2 + 4 + 5 + 0 | 14/5 = 2.8      |    2.8000            3.0000
    |    12 | mina1111 |       1 |        8 | 2 + 4 + 5 + 0 + 1 | 12/5 = 2.4      |    2.4000            2.5000
    |    13 | mina1111 |       1 |        9 | 4 + 5 + 0 + 1 + 1 | 11/5 = 2.2      |    2.2000            2.2000
    +-------+----------+---------+----------+-------------------+-----------------+

     

  4. The process you described aboved only verifies to the user that they entered the email correctly. It does nothing to verify it from your point of view. Until they respond to your email to verify receipt within a prescribed timeframe, you have no idea whether the email was valid or not.

  5. My solution requires just the records for mina1111 with consecutive record numbers (to facilitate finding the last 5 records) so I created a temporary table from your data. Also because I needed to reference the table a second time in a subquery (you can;t do this with temp tables) I had to create a second temporary table.

    I'm afraid it isn't the most efficient query ever written as it uses a dependent subquery.

        --
        -- create temp table a
        --
    create temporary table mina1111_a
    select a.recno
         , a.v_score
         , @count := @count+1 as reccount
    from ajoo a
         JOIN (select @count:=0) as init
    where user = 'mina1111';
    
        --
        -- create temp table b
        --
    create temporary table mina1111_b
    select a.recno
         , a.v_score
         , @count := @count+1 as reccount
    from ajoo a
         JOIN (select @count:=0) as init
    where user = 'mina1111';
    
        --
        -- calculate rolling 5-record averages
        --
    SELECT a.recno
         , j.user
         , a.v_score
         , a.reccount
         , ( SELECT AVG(b.v_score) as avscor 
             FROM 
                 mina1111_b b
             WHERE reccount BETWEEN a.reccount-4 and a.reccount
           ) as av5
    FROM mina1111_a a
    JOIN ajoo j using (recno) 
    WHERE a.reccount > 4;
    
        --
        -- remove the temporary tables
        --
    drop temporary table mina1111_a;
    drop temporary table mina1111_b;

    results...

    +-------+----------+---------+----------+--------+
    | recno | user     | v_score | reccount | av5    |
    +-------+----------+---------+----------+--------+
    |     9 | mina1111 |       4 |        5 | 3.0000 |
    |    10 | mina1111 |       5 |        6 | 3.6000 |
    |    11 | mina1111 |       0 |        7 | 2.8000 |
    |    12 | mina1111 |       1 |        8 | 2.4000 |
    |    13 | mina1111 |       1 |        9 | 2.2000 |
    +-------+----------+---------+----------+--------+

    Temporary table...

    +-------+---------+----------+
    | recno | v_score | reccount |
    +-------+---------+----------+
    |     3 |       2 |        1 |
    |     6 |       4 |        2 |
    |     7 |       3 |        3 |
    |     8 |       2 |        4 |
    |     9 |       4 |        5 |
    |    10 |       5 |        6 |
    |    11 |       0 |        7 |
    |    12 |       1 |        8 |
    |    13 |       1 |        9 |
    +-------+---------+----------+

     

    • Great Answer 1
  6. 59 minutes ago, Gherky said:

    Unit A image, Skill 1 text, Skill 2 text.

    To display that information you need to have it stored somewhere, so you have to decide where and how to make it easily accessible. Your options are

    1. in the code (this means rewriting the code if you want to make additions or changes)
    2. in a file
    3. in a database (probably overkill for this application)

    ... which leaves option 2.

     

  7. The reply form lists accepted file types

    Quote

    Accepted file types gif, jpeg, jpe, jpg, png, mp4, 3gp, mov, ogg, ogv, mpg, mpeg, flv, webm, wmv, avi, m4v

    EG

    register.PNG.6c53f7dc3e6e1f6e681ac7e47be34dc3.PNG

    Text, such as a SQL data dump, can be placed inside (<>) code frames. EG

    DROP TABLE IF EXISTS `result`;
    /*!40101 SET @saved_cs_client     = @@character_set_client */;
    /*!40101 SET character_set_client = utf8 */;
    CREATE TABLE `result` (
      `pupilid` int(10) unsigned NOT NULL,
      `subjectid` int(10) unsigned NOT NULL,
      `pcent` tinyint(4) DEFAULT '0',
      `schoolyear` int(4) NOT NULL DEFAULT '0',
      `resultid` int(10) unsigned NOT NULL AUTO_INCREMENT,
      PRIMARY KEY (`resultid`),
      KEY `index_2` (`pupilid`),
      KEY `index_3` (`subjectid`)
    ) ENGINE=MyISAM AUTO_INCREMENT=163 DEFAULT CHARSET=latin1;
    /*!40101 SET character_set_client = @saved_cs_client */;
    
    --
    -- Dumping data for table `result`
    --
    
    LOCK TABLES `result` WRITE;
    /*!40000 ALTER TABLE `result` DISABLE KEYS */;
    INSERT INTO `result` VALUES (1,1,78,2014,1),(3,1,58,2014,2),(4,1,54,2014,3),(8,1,91,2014,4),(9,1,62,2014,5),
    (11,1,77,2014,6),(13,1,60,2014,7),(14,1,64,2014,8),(15,1,93,2014,9),(18,1,87,2014,10),
    (19,1,60,2014,11),(20,1,81,2014,12),(1,2,87,2014,13),(2,2,53,2014,14),(4,2,87,2014,15),
    (12,2,93,2014,16),(14,2,62,2014,17),(15,2,74,2014,18),(16,2,90,2014,19),(17,2,87,2014,20),
    (21,2,73,2014,21),(22,2,53,2014,22),(23,2,86,2014,23),(2,3,88,2014,24),(5,3,85,2014,25),
    (6,3,68,2014,26),(8,3,78,2014,27),(12,3,50,2014,28),(19,3,53,2014,29),(7,4,69,2014,30),
    (10,4,90,2014,31),(13,4,57,2014,32),(19,4,57,2014,33),(22,4,62,2014,34),(23,4,92,2014,35),
    (24,4,95,2014,36),(1,5,79,2014,37),(2,5,76,2014,38),(5,5,94,2014,39),(7,5,58,2014,40),
    (9,5,50,2014,41),(11,5,68,2014,42),(14,5,51,2014,43),(18,5,94,2014,44),(20,5,86,2014,45),
    (21,5,52,2014,46),(22,5,87,2014,47),(23,5,53,2014,48),(24,5,86,2014,49),(6,6,87,2014,50),
    (10,6,81,2014,51),(13,6,51,2014,52),(22,6,54,2014,53),(23,6,67,2014,54),(24,6,77,2014,55),
    (6,7,92,2014,56),(9,7,89,2014,57),(10,7,74,2014,58),(14,7,53,2014,59),(18,7,86,2014,60),
    (21,7,85,2014,61),(2,8,71,2014,62),(4,8,52,2014,63),(5,8,89,2014,64),(7,8,58,2014,65),
    (11,8,63,2014,66),(16,8,93,2014,67),(17,8,91,2014,68),(20,8,82,2014,69),(21,8,87,2014,70),
    (24,8,93,2014,71),(3,9,66,2014,72),(4,9,90,2014,73),(5,9,69,2014,74),(6,9,69,2014,75),
    (9,9,87,2014,76),(13,9,91,2014,77),(15,9,54,2014,78),(17,9,84,2014,79),(18,9,72,2014,80),
    (19,9,58,2014,81),(1,1,73,2015,82),(3,1,95,2015,83),(4,1,84,2015,84),(8,1,73,2015,85),
    (9,1,93,2015,86),(11,1,71,2015,87),(13,1,93,2015,88),(14,1,79,2015,89),(15,1,94,2015,90),
    (18,1,60,2015,91),(19,1,71,2015,92),(20,1,77,2015,93),(1,2,74,2015,94),(2,2,81,2015,95),
    (4,2,85,2015,96),(12,2,83,2015,97),(14,2,63,2015,98),(15,2,81,2015,99),(16,2,82,2015,100),
    (17,2,70,2015,101),(21,2,82,2015,102),(22,2,66,2015,103),(23,2,60,2015,104),(2,3,82,2015,105),
    (5,3,96,2015,106),(6,3,96,2015,107),(8,3,93,2015,108),(12,3,82,2015,109),(19,3,73,2015,110),
    (7,4,94,2015,111),(10,4,81,2015,112),(13,4,62,2015,113),(19,4,84,2015,114),(22,4,60,2015,115),
    (23,4,64,2015,116),(24,4,83,2015,117),(1,5,84,2015,118),(2,5,77,2015,119),(5,5,71,2015,120),
    (7,5,66,2015,121),(9,5,95,2015,122),(11,5,64,2015,123),(14,5,92,2015,124),(18,5,92,2015,125),
    (20,5,88,2015,126),(21,5,65,2015,127),(22,5,77,2015,128),(23,5,93,2015,129),(24,5,61,2015,130),
    (6,6,79,2015,131),(10,6,77,2015,132),(13,6,88,2015,133),(22,6,76,2015,134),(23,6,93,2015,135),
    (24,6,62,2015,136),(6,7,86,2015,137),(9,7,69,2015,138),(10,7,69,2015,139),(14,7,76,2015,140),
    (18,7,77,2015,141),(21,7,96,2015,142),(2,8,78,2015,143),(4,8,77,2015,144),(5,8,95,2015,145),
    (7,8,68,2015,146),(11,8,74,2015,147),(16,8,67,2015,148),(17,8,91,2015,149),(20,8,83,2015,150),
    (21,8,80,2015,151),(24,8,93,2015,152),(3,9,88,2015,153),(4,9,66,2015,154),(5,9,81,2015,155),
    (6,9,73,2015,156),(9,9,61,2015,157),(13,9,66,2015,158),(15,9,86,2015,159),(17,9,60,2015,160),
    (18,9,94,2015,161),(19,9,79,2015,162);
    /*!40000 ALTER TABLE `result` ENABLE KEYS */;
    UNLOCK TABLES;

     

  8. Looks like it's just the quotes that are missing IE use

    <img src="<?php echo $path['t'];?>"/>

    But as that is what the code is doing for you anyway it isn't going to cure the problem of images not appearing. You could try

    <img src="<?php echo $path['o'];?>"/>

    or

    <img src="<?php echo $path['src'];?>"/>

    If none of those work then the images ain't there anymore.

    • Great Answer 1
  9. The error is nothing to do with the upgrade, except that error reporting got turned on.

    When PHP comes across an unquoted string then it assumes it is a defined constant. It then searches for the definition. Not finding a definition it then assumes it is string literal ("t"). This is only a warning and doesn't affect the running of the code (other than slowing it down while it searches for a constant definition).

    The question is, therefore, "Is there a key "t" in the $path array?"

    Try adding a line of code to debug...

    <?php $images = get_group('Banner Images'); ?>
                <?php
                echo '<pre>.print_r($images, true).'</pre>';    // ADD THIS LINE
                foreach ($images as $image) {
                   . . .

    Post the output from that line so we can see the data.

    • Like 1
  10. This is my take on it. I copy/pasted a couple of extra jobs to give...

     

    image.thumb.png.a04f143031066d53eb7b5efc1880b884.png

    CODE

    <?php
    $required = ['Feasibility', 'Measure Up', 'Model Drawing', 'Concept Design', 'Developed Design', 'Resource Consent', 'Construction Documentation' ];
    
    $colors =   array_combine($required, ['w3-red', 'w3-green', 'w3-orange', 'w3-deep-orange', 'w3-teal', 'w3-yellow', 'w3-purple'] );
    
    $staff_arr = [ 'Staff1' => 'SP',
                   'Staff2' => 'MB',
                   'Staff3' => 'BF',
                   'Staff4' => 'MCP',
                   'Staff5' => 'DG'
                 ];
    
    function state_dropdown($staff, $color)
    {
        return "<form action='' method='POST'>" .
         "<select class='w3-input w3-round $color' name ='StaffName' onchange='this.form.submit()'>" .                       // why is a menu of states called "StaffName" ?
         "<option value =''>$staff</option>" . 
         "<option class='form-control col-sm-3 bg-white text-dark'>Feasibility </option> " .      
         "<option class='form-control col-sm-3 bg-white text-dark'>Measure Up </option> " .                  
         "<option class='form-control col-sm-3 bg-white text-dark'>Model Drawing </option> " .                  
         "<option class='form-control col-sm-3 bg-white text-dark'>Concept Design </option> " . 
         "<option class='form-control col-sm-3 bg-white text-dark'>Developed Design </option> " . 
         "<option class='form-control col-sm-3 bg-white text-dark'>Resource Consent </option> " . 
         "<option class='form-control col-sm-3 bg-white text-dark'>Construction Docs  </option> " .            
         "</select>" .
         "</form>";
    }
      
      
    $xml = simplexml_load_file('plugnz.xml');
    $data = [];
    
    //
    //  collect the jobs and current task data into an array
    //
    foreach ($xml->Jobs->Job as $job) {
        $id = (string)$job->ID;
        $state = (string)$job->State;
        if (!in_array($state, $required)) continue;
        
        $data[$id] = [ 'name' => (string)$job->Name,
                       'state' => $state
                     ];
        $tasks = $job->xpath("Tasks/Task[Name='$state']");
        $clr = $colors[$state];
        $due = (string)$tasks[0]->DueDate;
        $data[$id]['due'] = date('Y-m-d', strtotime($due));
        $data[$id]['display_date'] = date('M d Y', strtotime($due));
        
        $assigned = [];
        foreach ($tasks[0]->Assigned->Staff as $s) {
            $assigned[] = $staff_arr[(string)$s->Name];
        }
        $staff_str = join(' ', $assigned);
        $data[$id]['task'] = [ 'staff' => $staff_str, 'clr' => $clr ];
    }
    
    //
    //  sort the data array on the task due date DESC
    //
    uasort($data, function($a,$b) { return $b['due'] <=> $a['due']; } );
    
    //
    // output the array as a table
    //
    $tdata = '';
    foreach ($data as $jid => $jdata) {
        $tdata .= "<tr><td class='jobno'>$jid</td><td>{$jdata['name']}</td>";
        foreach ($required as $stat) {
            if ($jdata['state']==$stat) {
                $tdata .= "<td>" . state_dropdown($jdata['task']['staff'], $jdata['task']['clr']) . "</td>";
            }
            else {
                $tdata .= "<td>&nbsp;</td>";
            }
        }
        $tdata .= "<td>&nbsp;</td>";
        $tdata .= "<td>{$jdata['display_date']}</td></tr>";
    }
    
    ?>
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="creation-date" content="05/10/2019">
    <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <title>Job Status Table</title>
    <style type="text/css">
        body { font-family: verdana,sans-serif; font-size: 10pt; padding: 20px 50px; }
        table {border-collapse: collapse;}
        .th-sm-1 { font-size: 8pt; text-align: left; }
        .jobno   { font-weight: 600; color: #2196f3; }
        select   { width: 120px; }
    </style>
    </head>
    <body>
        <table border=1>
            <thead>
            <tr>
              <th class="th-sm-1">Project Number</th>
              <th class="th-sm-1">Project Name</th>  
              <th class="th-sm-1">Feasibility</th>
              <th class="th-sm-1">Measure Up</th>
              <th class="th-sm-1">Model Drawing</th>
              <th class="th-sm-1">Concept Design</th>
              <th class="th-sm-1">Developed Design</th>
              <th class="th-sm-1">Resource Consent</th>
              <th class="th-sm-1">Construction Docs</th>
              <th class="th-sm-1">Milestone</th>
              <th class="th-sm-1">Due Date</th>
            </tr>
            </thead>
            <tbody>
                <?=$tdata?>
            </tbody>    
        </table>
    </body>
    </html>

     

    • Like 2
  11. P.S.

    I would recommend a checkbox which the user has to click (check) to verify age. Local storage would have to be set in the javascript.

    <!DOCTYPE html>
    <html>
    <head>
        <meta http-equiv="content-language" content="en">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Example</title>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <script type="text/javascript">
            
            function ageVerified(btn)
            {
                if ($(btn).is(":checked") && $(btn).val() == 'Yes' ) {
                    localStorage.setItem('age_verification', 'Yes')
                }
                else {
                    localStorage.setItem('age_verification', 'No')
                }
            }
            
        </script>
    </head>
    <body>
    
        <form method="post">
            I am over 18 &emsp; 
                <input type="checkbox" name="ageverify" onclick="ageVerified(this)" value="Yes">
                <br>
            <input type="submit" name="btnSub" value="Submit">
        </form>
    
    </body>
    </html>

    Alternatively, use a pair of radio buttons. Either way it's a single input...

        <form method="post">
            I am over 18 &emsp; 
                <input type="radio" name="ageverify" onclick="ageVerified(this)" value="No" checked> No &emsp; 
                <input type="radio" name="ageverify" onclick="ageVerified(this)" value="Yes"> Yes
            <br>
            <input type="submit" name="btnSub" value="Submit">
        </form>

    Whichever above method you use, the PHP processing would be the same ...

    <?php
    
    if ( ($_POST['ageverify'] ?? 'No') == 'Yes')  {
        echo "User is over 18<hr>";
    }
    else {
        echo "Under age user<hr>" ;
    }
    
    ?>

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.