Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. There is no code there to process the id that was selected, so all you are doing is repeatedly loading the same page and expecting different results by magic. You need to get id value from $_GET['id'] and use that to retrieve the data you want to display then display it.
  2. When you click the "View" button you go to "newdisplay.php". What is the value of the id in address bar at the top? Does it match the one you clicked? What are doing with that id value that is passed to the page? (The code?) [edit...] After a closer look at you link I see it contains a submit input. WHY? Is that taking precedence and just reloading the page? What happens if the link is <a href='newdisplay.php?id=$result[id]'>View<a/>
  3. Why are you suppressing error reporting then asking us what's wrong? The reporting is there to help you find errors. Use the code button when posting code.
  4. If I reverse the array (to give the same order that your sort is giving - DIFFERENT DEPO before TEST DEPO) I get Array ( [0] => Array ( [supplier] => TEST2 DEPO [rolanID] => Array ( [0] => 456 [1] => 188 [2] => 200 [3] => 123 ) [itemCount] => 4 ) [1] => Array ( [supplier] => DIFFERENT DEPO [rolanID] => Array ( [0] => 897 [1] => 487 [2] => 100 ) [itemCount] => 3 ) [2] => Array ( [supplier] => TEST DEPO [rolanID] => Array ( [1] => 234 ) [itemCount] => 1 ) )
  5. OK - I've added the sort usort($test, fn($a, $b) => $b['itemCount']<=>$a['itemCount']); // sort descending itemCount $seen = []; foreach ($test as $k => &$rec) { $rec['rolanID'] = array_diff($rec['rolanID'], $seen); // find new ids if ($rec['rolanID']) { // if there are some new ones ... $rec['itemCount'] = count($rec['rolanID']); // count them $seen = array_merge($seen, $rec['rolanID']); // add the new ones to those already seen } else unset($test[$k]); // if no ids, remove the array item } and I now get this (no duplicate 123)... Array ( [0] => Array ( [supplier] => TEST2 DEPO [rolanID] => Array ( [0] => 456 [1] => 188 [2] => 200 [3] => 123 ) [itemCount] => 4 ) [1] => Array ( [supplier] => TEST DEPO [rolanID] => Array ( [1] => 234 ) [itemCount] => 1 ) [2] => Array ( [supplier] => DIFFERENT DEPO [rolanID] => Array ( [0] => 897 [1] => 487 [2] => 100 ) [itemCount] => 3 ) )
  6. Using your new $test array with my code, I get this in the $test array... Array ( [0] => Array ( [supplier] => ROLAN [rolanID] => Array ( [0] => 456 ) [itemCount] => 1 ) [1] => Array ( [supplier] => ROLAN [rolanID] => Array ( [0] => 123 [1] => 234 ) [itemCount] => 2 ) [3] => Array ( [supplier] => DIFFERENT DEPO [rolanID] => Array ( [0] => 897 [1] => 487 [2] => 100 ) [itemCount] => 3 ) [4] => Array ( [supplier] => TEST2 DEPO [rolanID] => Array ( [1] => 188 [2] => 200 ) [itemCount] => 2 ) )
  7. Yes, you could.
  8. Does output of your $_GET array show an "id" key? echo '<pre>' . print_r($_GET, true) . '</pre>';
  9. Here's my solution $seen = []; foreach ($test as $k => &$rec) { $rec['rolanID'] = array_diff($rec['rolanID'], $seen); // find new ids if ($rec['rolanID']) { // if there are some new ones ... $rec['itemCount'] = count($rec['rolanID']); // count them $seen = array_merge($seen, $rec['rolanID']); // add the new ones to those already seen } else unset($test[$k]); // if no ids, remove the array item } +-----------------------------------------------+ | | | $test ARRAY - AFTER | | | +-----------------------------------------------+ | | | Array | | ( | | [0] => Array | | ( | | [supplier] => TEST DEPO | | [rolanID] => Array | | ( | | [0] => 123 | | [1] => 234 | | [2] => 456 | | ) | | | | [itemCount] => 3 | | ) | | | | [1] => Array | | ( | | [supplier] => ANOTHER DEPO | | [rolanID] => Array | | ( | | [1] => 786 | | [2] => 345 | | ) | | | | [itemCount] => 2 | | ) | | ) | | | +-----------------------------------------------+
  10. I feel your pain. Fetch syntax is far too cryptic for me.
  11. Google turned up this https://rapidapi.com/guides/fetch-api-async-await
  12. Yes - line 7. Plus it's normal to specify a default database. Depends what you want to do with it and what operating system you are using.
  13. Is there an item in your $_GET array with the key "c.id"? I suspect it will be just $_GET["id"] as you were originally using.
  14. Would this work? $results = array_filter($results, fn($v) => in_array($v->iso_639_1, ['en','fr']) && $v->type == 'Trailer' && $v->site == 'YouTube' ); rsort($results); // 'fr' first then 'en' results foreach ($results as $r) { echo "{$r->iso_639_1} &ndash; {$r->name}<br>"; }
  15. I can't imagine anyone attempting to edit that amount of pastebin data to make it suitable to test any solution. Post a json_encoded version of the array here so we have something useable. PS and post the code you have so far - it may give us a clue to what you are talking about.
  16. Breakfast and two coffees in the morning are my minimum requirement.
  17. You find that out with a process commonly known as "testing" (You might want to Google that)
  18. The one with braces will work, the other won't even run.
  19. If that's how you want the layout to look. Only you know that.
  20. Then append those to the content too.
  21. Similar data but solution is more complicated with this one
  22. You have a form which has been designed to produce invoices one month at a time - there is only the option to enter a singlw month First thing to do is redesign the form to allow the specification of multiple months. For example a month menu allowing multiple selections, or 12 checkboxes, or have fields to specify number of months and starting month (4 months starting at August) Then change the processing of the submitted form to produce the invoice records for those months.
×
×
  • 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.