Jump to content

Barand

Moderators
  • Posts

    22,441
  • Joined

  • Last visited

  • Days Won

    623

Everything posted by Barand

  1. 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?
  2. Where is the value for $userLoggedin coming from?
  3. 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 ) )
  4. 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?)
  5. It could've been created in a previous month. ("yydd" occurs 12 times per year if dd <= 28)
  6. COALESCE() comes in useful here SELECT ... FROM tablename WHERE COALESCE(colname, '') = '';
  7. 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?
  8. 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);
  9. 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
  10. It does center the text, but your inline heading is only as wide as its content (as adding a border shows)
  11. 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 ?>
  12. 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
  13. 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.
  14. echo "$game[6] $game[7]/$game[4] $game[5] $game[9] $game[10] $game[11] - $game[12] $game[13] $game[14]"; is redundant
  15. 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.
  16. (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
  17. Have you tried using mysqil's error reporting to find the reason?
  18. 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.
  19. If the php code didn't work when it was a .html file but did work when changed to a .php file, then that should be a clue. The default configuration on most servers is that php code must be in a .php file to be processed. A .php file may contain html (in fact it doesn't need to contain any php!).
  20. Is the file that the code is in a .PHP file or a .HTML file? If it's not .php, rename it and try again.
  21. Is that so difficult to understand?
  22. is it feasible for your app to store the data as they interact with the various api's?
  23. Also your css style specification is for images with class=logo. You don't have one, you have a div with class=logo.
  24. Store id if login successful if (password_verify($_POST['password'], $row['password'])) { $_SESSION['user_id'] = $_POST['user_id']; } else { // error - invalid login } Get and display points if (isset($_SESSION['user_id'])) { $res = $conn->prepare("SELECT points FROM user_points WHERE user_id = ? "); $res->execute([${SESSION['user_id']}]); echo "You have " . $res->fetchColumn(). " points<br>"; } else { header("Location: login.php"); // send to login page }
×
×
  • 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.