Jump to content

Barand

Moderators
  • Content Count

    19,520
  • Joined

  • Last visited

  • Days Won

    392

Barand last won the day on August 21

Barand had the most liked content!

Community Reputation

1,327 Excellent

3 Followers

About Barand

Profile Information

Recent Profile Visitors

57,949 profile views
  1. The reply form lists accepted file types EG 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;
  2. 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.
  3. 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.
  4. "user_id" would be a useful addition to each of those tables
  5. When a user logs in, where in your code is the id of that user stored? In my example in my previous post, <id of current user> should be that value, not another column in your data.
  6. This is my take on it. I copy/pasted a couple of extra jobs to give... 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>
  7. 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>" ; } ?>
  8. You are trying to mix javascript code and PHP. You can't (they run in different places at different times). Why does your form have an input for "yes" and a separate one for "no"?
  9. That is the only selection condition in your query so it displays every record with a non-zero date. You need to put a conditional expression in there to limit it to just the user's records. EG WHERE upv_time_date AND <user id of record> = <id of current user>
  10. Sorry - misread what you were saying - I thought the above was your instruction on what to to.
  11. If he removes the 'Z' timezone indicator it will assume the timestring is his default timeszone (BST) and not UTC, therefore he will need $tstr = '2019-08-13T13:30:00.000'; $dt = new DateTime($tstr, new DateTimeZone('UTC')); // specify UTC timezone to specify it is a UTC time. Otherwise he's back to where he started as his default is Europe/London already.
  12. It does... $tstr = '2019-08-13T13:30:00.000Z'; $dt = new DateTime($tstr); // create UTC datetime object $dt->setTimezone(new DateTimeZone("Europe/London")); // convert to BST echo $dt->format('Y-m-d H:i:s P'); //--> 2019-08-13 14:30:00 +01:00
  13. Given that xml extract $required = ['Feasibility', 'Measure Up', 'Model Drawing', 'Concept Design', 'Developed Design', 'Resource Consent', 'Construction Documentation' ]; $str = <<<XML <Jobs> <Job> <ID></ID> <Name>Job 1</Name> <State>Concept Design</State> <StartDate>2019-02-01</StartDate> <DueDate>2019-10-01</DueDate> <Tasks> <Task> <ID></ID> <Name>Measure Up</Name> <StartDate>2019-07-01</StartDate> <DueDate>2019-07-30</DueDate> </Task> <Task> <ID></ID> <Name>Concept Design</Name> <StartDate>2019-08-01</StartDate> <DueDate>2019-08-31</DueDate> </Task> </Tasks> </Job> </Jobs> XML; $xml = simplexml_load_string($str); // echo '<pre>', print_r($xml, 1), '</pre>'; foreach ($xml->Job as $job) { $state = (string)$job->State; if (!in_array($state, $required)) continue; echo "{$job->Name} — $state — "; foreach ($job->Tasks->Task as $task) { if ($task->Name == $state) { echo $task->DueDate . '<br>'; } } } Output Job 1 — Concept Design — 2019-08-31 EDIT - Alternative method $xml = simplexml_load_string($str); foreach ($xml->xpath("//Job") as $job) { $state = (string)$job->State; if (!in_array($state, $required)) continue; echo "{$job->Name} &mdash; $state &mdash; "; $task = $job->xpath("//Task[Name='$state']") ; echo $task[0]->DueDate . '<br>'; }
  14. Any chance of the full XML? That doesn't seem to match up with your processing.
×
×
  • 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.