Jump to content

Barand

Moderators
  • Posts

    24,605
  • Joined

  • Last visited

  • Days Won

    830

Everything posted by Barand

  1. What do you see if you echo $sql; Is there a value at the end where the staff id should be?
  2. No it doesn't. Referencing field names that aren't in the table produces that error.
  3. Looks like you have a second datetime later on in the query (lastRain). You need to quote both.
  4. A date time value is a string and therefore needs to be in quotes VALUES ( '$_DateTime', $_tempf, ... Better still, use prepared queries to protect from SQL injection attacks. Don't put variables in the SQL query string.
  5. Look again at my code.
  6. Curly braces and endif don't play nice together. Use one syntax or the other. <?php if($chk == 0) { ?> <div id='showMe'> <div class="container"> <div class="row" style="color:red; padding-top:6rem; text-align:center;"> <h1>Database Update Failed</h1> </div> </div> </div> <?php } else { ?> <div id='showMe'> <div class="container"> <div class="row" style="padding-top:6rem; text-align:center;" > <h1><center>Database Update Successful</center></h1> </div> </div> </div> <?php } ?> </body> </html>
  7. Can you post the data returned by the api without all the var_dump junk in it? Can you post your code in a reasonably formatted manner?
  8. Where is the value for $userLoggedin coming from?
  9. Example $arr = [ [ 'A', 'Jan. 22, 22'], [ 'B', 'Dec. 25, 21'], [ 'C', 'Feb. 22, 22'], [ 'D', 'Jan. 2, 22'] ]; usort($arr, function($a, $b) { $da = DateTime::createFromFormat('M. j, y', $a[1]); $db = DateTime::createFromFormat('M. j, y', $b[1]); return $db <=> $da; }); echo '<pre>' . print_r($arr, 1) . '</pre>'; outputs Array ( [0] => Array ( [0] => C [1] => Feb. 22 22 ) [1] => Array ( [0] => A [1] => Jan. 22 22 ) [2] => Array ( [0] => D [1] => Jan. 2 22 ) [3] => Array ( [0] => B [1] => Dec. 25 21 ) )
  10. try echo "<a href='$latest_dir $latest_file'><button>"."continue</button></a><br>"; ^ ^ ... adding the single quotes, otherwise the href finishes at the space. (Are you sure you want the space?)
  11. It could've been created in a previous month. ("yydd" occurs 12 times per year if dd <= 28)
  12. COALESCE() comes in useful here SELECT ... FROM tablename WHERE COALESCE(colname, '') = '';
  13. If you do, tell us what your real problem is. At present you are telling us a solution that isn't working - because it's the wrong solution, perhaps?
  14. Use outer double quotes to insert a variable into a string. $cat_list = "<a href='blah'>cat 1</a>, <a href='yadayada'>cat 2</a>"; $cat_color = '#8F1FCF'; $cat_list = str_replace('<a', "<a style='color:$cat_color'", $cat_list);
  15. Barand

    $duration

    SImply by using the fact that there are 60 minutes in an hour and some very basic arithmetic. Therefore 0.67 hrs is 60 * 0.67 minutes (= 40 min) $t = 12.67; printf('%d hrs %d min', intval($t), ($t - intval($t))*60); //--> 12 hrs 40 min
  16. It does center the text, but your inline heading is only as wide as its content (as adding a border shows)
  17. try <?php $j = '{"JsonAssociationV1":{"transaction_type":"Create","main_train_uid":"G31259","assoc_train_uid":"G32783","assoc_start_date":"2021-12-13T00:00:00Z","assoc_end_date":"2022-05-13T00:00:00Z","assoc_days":"1111100","category":"NP","date_indicator":"S","location":"SHEFFLD","base_location_suffix":null,"assoc_location_suffix":null,"diagram_type":"T","CIF_stp_indicator":"P"}}'; $a = json_decode($j, 1); $type = $a['JsonAssociationV1']['transaction_type']; echo $type; // --> Create ?>
  18. Too many <..>s and echos. Try echo "<option value='$value'>$key</option>"; (Note use of outer double quotes) Please use the <> button when posting code
  19. Of course, the correct code could equally be echo ($class - $variacion); or echo ($class_variacion); but who can say as we have no idea what the line is supposed to do. "'cause de Hyphen" doesn't really cut it as an explanation.
  20. echo "$game[6] $game[7]/$game[4] $game[5] $game[9] $game[10] $game[11] - $game[12] $game[13] $game[14]"; is redundant
  21. The code you posted above outputs this for me (changed only by adjusting newlines and tabs) <div class="col-4"> <h5>Laker</h5> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="1" value="Adam Simms"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="7" value="David Powell"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="9" value="George Wilson"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="11" value="Jane Morrison"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="21" value="Peter Adamson"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="23" value="Wayne Jones"> </div> <div class="col-4"> <h5>Grace</h5> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="2" value="Allan Blair"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="5" value="Anthony Bell"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="6" value="Caroline Freeman"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="14" value="John Watson"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="15" value="Jack Williams"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="19" value="Mary Whitehouse"> </div> <div class="col-4"> <h5>Jardine</h5> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="4" value="Anne Bailey"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="12" value="John Patterson"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="13" value="John Tully"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="18" value="Mary Sheldon"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="20" value="Michael Grove"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="22" value="Peter Appleby"> </div> <div class="col-4"> <h5>Cowdrey</h5> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="3" value="Anna Hamilton"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="8" value="Emma Watson"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="10" value="Henry Irving"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="16" value="Margaret Norton"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="17" value="Mary Blake"> <input class="form-control w-100 mb-3" type="text" disabled="disabled" name="" data-value="24" value="William Smith"> </div> No col-6s and nothing rogue.
  22. (This example uses the "house" and "pupil" tables from my SQL tutorials instead of your teams and players) $res = $db->query("SELECT h.house_name , p.fname , p.lname FROM house h JOIN pupil p USING (houseid) "); $data = []; foreach ($res as $row) { if (!isset($data[$row['house_name']])) { $data[$row['house_name']] = []; } $data[$row['house_name']][] = [$row['fname'], $row['lname']]; } foreach ($data as $house => $pupils) { echo "$house<ul>"; foreach ($pupils as $p) { echo "<li>{$p[0]} {$p[1]}</li>"; } echo "</ul>"; } giving
  23. Have you tried using mysqil's error reporting to find the reason?
  24. number has not been assigned a value in that code $x and $y are php variables and will not be available when the javascript runs.
×
×
  • 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.