Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. If you look at the html source you will see that it is the same as before... <input class="form-control" type="text" value=Information and Technology disabled readonly> It needs to be <input class="form-control" type="text" value="Information and Technology" disabled readonly> ^ ^ The php needs to be <?php echo '<input class="form-control" type="text" value="'.$CategoryName.'" disabled readonly>'; ?> or, using a double-quoted string <?php echo "<input class='form-control' type='text' value=\"$CategoryName\" disabled readonly>"; ?>
  2. There are a couple of solutions that you can apply on the MySql side. 1 ) Use mysql's ROUND() function i your query mysql> create temporary table test1 (amount float); mysql> insert into test1 (amount) Values (PI()); mysql> select amount, round(amount, 1) as rounded from test1; +---------+---------+ | amount | rounded | +---------+---------+ | 3.14159 | 3.1 | +---------+---------+ 1 row in set (0.03 sec) 2 ) Define the column as DECIMAL instead of FLOAT mysql> create temporary table test2 (amount DECIMAL(8,1)); mysql> insert into test2 (amount) Values (PI()); mysql> select amount from test2; +--------+ | amount | +--------+ | 3.1 | +--------+ 1 row in set (0.00 sec)
  3. Because that is the array you want to sort? It wasn't really necessary as usort($data['listings'] would have done the same thing. But I felt your array had a surfeit of levels.
  4. You were advised to use usort(). Your custom function would compare the totals of each pair of records ($a and $b) and return a negative value if $a should sort before $b or positive if $a sorts after $b. (ie total A - total B) $listings = $data['listings']; usort($listings, function($a, $b) { return $a['item_price']['value'] + $a['postage']['price']['value'] - $b['item_price']['value'] - $b['postage']['price']['value']; }); echo '<pre>' . print_r($listings, 1) . '</pre>';
  5. Dates need to be Ymd (or Y-m-d) to be sortable
  6. try using a custom sort function # # Sort attendees on course, name # usort($attendees, function($a, $b) { $x = $a['course']<=>$b['course']; if ($x == 0) return $a['name']<=>$b['name']; return $x; }); # # Add sorted attendees to result array # $result = array(); foreach ($attendees as $attendee): $result[$attendee['course']][] = $attendee; endforeach; # # View result # echo '<pre>' . print_r($result, 1) . '</pre>'; P.S. You didn't say in what order you want them. If your aim is merely to get the courses in order then you could use ksort($result) (instead of your current sort() )to order the keys.
  7. It's been a particularly miserable , grey, rainy sort of a day so I passed some time on this <?php $json = '{"meta":{"count":5,"links":{"self":"https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=CPT&destinationLocationCode=LGW&departureDate=2023-03-01&returnDate=2023-03-08&adults=1&travelClass=ECONOMY¤cyCode=ZAR&max=5"}},"data":[{"type":"flight-offer","id":"1","source":"GDS","instantTicketingRequired":false,"nonHomogeneous":false,"oneWay":false,"lastTicketingDate":"2023-03-01","numberOfBookableSeats":7,"itineraries":[{"duration":"PT18H50M","segments":[{"departure":{"iataCode":"CPT","at":"2023-03-01T12:55:00"},"arrival":{"iataCode":"DOH","at":"2023-03-01T23:40:00"},"carrierCode":"QR","number":"1372","aircraft":{"code":"77W"},"operating":{"carrierCode":"QR"},"duration":"PT9H45M","id":"5","numberOfStops":0,"blacklistedInEU":false},{"departure":{"iataCode":"DOH","at":"2023-03-02T01:15:00"},"arrival":{"iataCode":"LGW","terminal":"S","at":"2023-03-02T05:45:00"},"carrierCode":"QR","number":"5943","aircraft":{"code":"777"},"operating":{"carrierCode":"BA"},"duration":"PT7H30M","id":"6","numberOfStops":0,"blacklistedInEU":false}]},{"duration":"PT19H10M","segments":[{"departure":{"iataCode":"LGW","terminal":"S","at":"2023-03-08T14:05:00"},"arrival":{"iataCode":"DOH","at":"2023-03-08T23:45:00"},"carrierCode":"QR","number":"5942","aircraft":{"code":"777"},"operating":{"carrierCode":"BA"},"duration":"PT6H40M","id":"7","numberOfStops":0,"blacklistedInEU":false},{"departure":{"iataCode":"DOH","at":"2023-03-09T02:15:00"},"arrival":{"iataCode":"CPT","at":"2023-03-09T11:15:00"},"carrierCode":"QR","number":"1369","aircraft":{"code":"77W"},"operating":{"carrierCode":"QR"},"duration":"PT10H","id":"8","numberOfStops":0,"blacklistedInEU":false}]}],"price":{"currency":"ZAR","total":"12632.45","base":"6370.00","fees":[{"amount":"0.00","type":"SUPPLIER"},{"amount":"0.00","type":"TICKETING"}],"grandTotal":"12632.45"},"pricingOptions":{"fareType":["PUBLISHED"],"includedCheckedBagsOnly":true},"validatingAirlineCodes":["QR"],"travelerPricings":[{"travelerId":"1","fareOption":"STANDARD","travelerType":"ADULT","price":{"currency":"ZAR","total":"12632.45","base":"6370.00"},"fareDetailsBySegment":[{"segmentId":"5","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}},{"segmentId":"6","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}},{"segmentId":"7","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}},{"segmentId":"8","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}}]}]},{"type":"flight-offer","id":"2","source":"GDS","instantTicketingRequired":false,"nonHomogeneous":false,"oneWay":false,"lastTicketingDate":"2023-03-01","numberOfBookableSeats":7,"itineraries":[{"duration":"PT19H15M","segments":[{"departure":{"iataCode":"CPT","at":"2023-03-01T19:10:00"},"arrival":{"iataCode":"DOH","at":"2023-03-02T05:55:00"},"carrierCode":"QR","number":"1370","aircraft":{"code":"77W"},"operating":{"carrierCode":"QR"},"duration":"PT9H45M","id":"1","numberOfStops":0,"blacklistedInEU":false},{"departure":{"iataCode":"DOH","at":"2023-03-02T08:05:00"},"arrival":{"iataCode":"LGW","terminal":"N","at":"2023-03-02T12:25:00"},"carrierCode":"QR","number":"327","aircraft":{"code":"788"},"operating":{"carrierCode":"QR"},"duration":"PT7H20M","id":"2","numberOfStops":0,"blacklistedInEU":false}]},{"duration":"PT19H10M","segments":[{"departure":{"iataCode":"LGW","terminal":"S","at":"2023-03-08T14:05:00"},"arrival":{"iataCode":"DOH","at":"2023-03-08T23:45:00"},"carrierCode":"QR","number":"5942","aircraft":{"code":"777"},"operating":{"carrierCode":"BA"},"duration":"PT6H40M","id":"7","numberOfStops":0,"blacklistedInEU":false},{"departure":{"iataCode":"DOH","at":"2023-03-09T02:15:00"},"arrival":{"iataCode":"CPT","at":"2023-03-09T11:15:00"},"carrierCode":"QR","number":"1369","aircraft":{"code":"77W"},"operating":{"carrierCode":"QR"},"duration":"PT10H","id":"8","numberOfStops":0,"blacklistedInEU":false}]}],"price":{"currency":"ZAR","total":"12632.45","base":"6370.00","fees":[{"amount":"0.00","type":"SUPPLIER"},{"amount":"0.00","type":"TICKETING"}],"grandTotal":"12632.45"},"pricingOptions":{"fareType":["PUBLISHED"],"includedCheckedBagsOnly":true},"validatingAirlineCodes":["QR"],"travelerPricings":[{"travelerId":"1","fareOption":"STANDARD","travelerType":"ADULT","price":{"currency":"ZAR","total":"12632.45","base":"6370.00"},"fareDetailsBySegment":[{"segmentId":"1","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}},{"segmentId":"2","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}},{"segmentId":"7","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}},{"segmentId":"8","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}}]}]},{"type":"flight-offer","id":"3","source":"GDS","instantTicketingRequired":false,"nonHomogeneous":false,"oneWay":false,"lastTicketingDate":"2023-03-01","numberOfBookableSeats":7,"itineraries":[{"duration":"PT25H30M","segments":[{"departure":{"iataCode":"CPT","at":"2023-03-01T12:55:00"},"arrival":{"iataCode":"DOH","at":"2023-03-01T23:40:00"},"carrierCode":"QR","number":"1372","aircraft":{"code":"77W"},"operating":{"carrierCode":"QR"},"duration":"PT9H45M","id":"3","numberOfStops":0,"blacklistedInEU":false},{"departure":{"iataCode":"DOH","at":"2023-03-02T08:05:00"},"arrival":{"iataCode":"LGW","terminal":"N","at":"2023-03-02T12:25:00"},"carrierCode":"QR","number":"327","aircraft":{"code":"788"},"operating":{"carrierCode":"QR"},"duration":"PT7H20M","id":"4","numberOfStops":0,"blacklistedInEU":false}]},{"duration":"PT19H10M","segments":[{"departure":{"iataCode":"LGW","terminal":"S","at":"2023-03-08T14:05:00"},"arrival":{"iataCode":"DOH","at":"2023-03-08T23:45:00"},"carrierCode":"QR","number":"5942","aircraft":{"code":"777"},"operating":{"carrierCode":"BA"},"duration":"PT6H40M","id":"7","numberOfStops":0,"blacklistedInEU":false},{"departure":{"iataCode":"DOH","at":"2023-03-09T02:15:00"},"arrival":{"iataCode":"CPT","at":"2023-03-09T11:15:00"},"carrierCode":"QR","number":"1369","aircraft":{"code":"77W"},"operating":{"carrierCode":"QR"},"duration":"PT10H","id":"8","numberOfStops":0,"blacklistedInEU":false}]}],"price":{"currency":"ZAR","total":"12632.45","base":"6370.00","fees":[{"amount":"0.00","type":"SUPPLIER"},{"amount":"0.00","type":"TICKETING"}],"grandTotal":"12632.45"},"pricingOptions":{"fareType":["PUBLISHED"],"includedCheckedBagsOnly":true},"validatingAirlineCodes":["QR"],"travelerPricings":[{"travelerId":"1","fareOption":"STANDARD","travelerType":"ADULT","price":{"currency":"ZAR","total":"12632.45","base":"6370.00"},"fareDetailsBySegment":[{"segmentId":"3","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}},{"segmentId":"4","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}},{"segmentId":"7","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}},{"segmentId":"8","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}}]}]},{"type":"flight-offer","id":"4","source":"GDS","instantTicketingRequired":false,"nonHomogeneous":false,"oneWay":false,"lastTicketingDate":"2023-03-01","numberOfBookableSeats":7,"itineraries":[{"duration":"PT18H50M","segments":[{"departure":{"iataCode":"CPT","at":"2023-03-01T12:55:00"},"arrival":{"iataCode":"DOH","at":"2023-03-01T23:40:00"},"carrierCode":"QR","number":"1372","aircraft":{"code":"77W"},"operating":{"carrierCode":"QR"},"duration":"PT9H45M","id":"5","numberOfStops":0,"blacklistedInEU":false},{"departure":{"iataCode":"DOH","at":"2023-03-02T01:15:00"},"arrival":{"iataCode":"LGW","terminal":"S","at":"2023-03-02T05:45:00"},"carrierCode":"QR","number":"5943","aircraft":{"code":"777"},"operating":{"carrierCode":"BA"},"duration":"PT7H30M","id":"6","numberOfStops":0,"blacklistedInEU":false}]},{"duration":"PT19H10M","segments":[{"departure":{"iataCode":"LGW","terminal":"N","at":"2023-03-08T14:05:00"},"arrival":{"iataCode":"DOH","at":"2023-03-08T23:50:00"},"carrierCode":"QR","number":"328","aircraft":{"code":"788"},"operating":{"carrierCode":"QR"},"duration":"PT6H45M","id":"9","numberOfStops":0,"blacklistedInEU":false},{"departure":{"iataCode":"DOH","at":"2023-03-09T02:15:00"},"arrival":{"iataCode":"CPT","at":"2023-03-09T11:15:00"},"carrierCode":"QR","number":"1369","aircraft":{"code":"77W"},"operating":{"carrierCode":"QR"},"duration":"PT10H","id":"10","numberOfStops":0,"blacklistedInEU":false}]}],"price":{"currency":"ZAR","total":"12670.45","base":"6370.00","fees":[{"amount":"0.00","type":"SUPPLIER"},{"amount":"0.00","type":"TICKETING"}],"grandTotal":"12670.45"},"pricingOptions":{"fareType":["PUBLISHED"],"includedCheckedBagsOnly":true},"validatingAirlineCodes":["QR"],"travelerPricings":[{"travelerId":"1","fareOption":"STANDARD","travelerType":"ADULT","price":{"currency":"ZAR","total":"12670.45","base":"6370.00"},"fareDetailsBySegment":[{"segmentId":"5","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}},{"segmentId":"6","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}},{"segmentId":"9","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}},{"segmentId":"10","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}}]}]},{"type":"flight-offer","id":"5","source":"GDS","instantTicketingRequired":false,"nonHomogeneous":false,"oneWay":false,"lastTicketingDate":"2023-03-01","numberOfBookableSeats":9,"itineraries":[{"duration":"PT19H15M","segments":[{"departure":{"iataCode":"CPT","at":"2023-03-01T19:10:00"},"arrival":{"iataCode":"DOH","at":"2023-03-02T05:55:00"},"carrierCode":"QR","number":"1370","aircraft":{"code":"77W"},"operating":{"carrierCode":"QR"},"duration":"PT9H45M","id":"1","numberOfStops":0,"blacklistedInEU":false},{"departure":{"iataCode":"DOH","at":"2023-03-02T08:05:00"},"arrival":{"iataCode":"LGW","terminal":"N","at":"2023-03-02T12:25:00"},"carrierCode":"QR","number":"327","aircraft":{"code":"788"},"operating":{"carrierCode":"QR"},"duration":"PT7H20M","id":"2","numberOfStops":0,"blacklistedInEU":false}]},{"duration":"PT19H10M","segments":[{"departure":{"iataCode":"LGW","terminal":"N","at":"2023-03-08T14:05:00"},"arrival":{"iataCode":"DOH","at":"2023-03-08T23:50:00"},"carrierCode":"QR","number":"328","aircraft":{"code":"788"},"operating":{"carrierCode":"QR"},"duration":"PT6H45M","id":"9","numberOfStops":0,"blacklistedInEU":false},{"departure":{"iataCode":"DOH","at":"2023-03-09T02:15:00"},"arrival":{"iataCode":"CPT","at":"2023-03-09T11:15:00"},"carrierCode":"QR","number":"1369","aircraft":{"code":"77W"},"operating":{"carrierCode":"QR"},"duration":"PT10H","id":"10","numberOfStops":0,"blacklistedInEU":false}]}],"price":{"currency":"ZAR","total":"12670.45","base":"6370.00","fees":[{"amount":"0.00","type":"SUPPLIER"},{"amount":"0.00","type":"TICKETING"}],"grandTotal":"12670.45"},"pricingOptions":{"fareType":["PUBLISHED"],"includedCheckedBagsOnly":true},"validatingAirlineCodes":["QR"],"travelerPricings":[{"travelerId":"1","fareOption":"STANDARD","travelerType":"ADULT","price":{"currency":"ZAR","total":"12670.45","base":"6370.00"},"fareDetailsBySegment":[{"segmentId":"1","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}},{"segmentId":"2","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}},{"segmentId":"9","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}},{"segmentId":"10","cabin":"ECONOMY","fareBasis":"NLR1R1RX","brandedFare":"ECLASSIC","class":"N","includedCheckedBags":{"quantity":2}}]}]}],"dictionaries":{"locations":{"CPT":{"cityCode":"CPT","countryCode":"ZA"},"DOH":{"cityCode":"DOH","countryCode":"QA"},"LGW":{"cityCode":"LON","countryCode":"GB"}},"aircraft":{"77W":"BOEING 777-300ER","777":"BOEING 777-200/300","788":"BOEING 787-8"},"currencies":{"ZAR":"S.AFRICAN RAND"},"carriers":{"QR":"QATAR AIRWAYS","BA":"BRITISH AIRWAYS"}}}'; $array = json_decode($json, true); $html = ''; foreach ($array['data'] as $offer) { $html .= buildOfferTable($offer); } function buildOfferTable($offer) { $html = "<div class='w3-row w3-padding w3-topbar'> <div class='w3-col w3-quarter'> Offer ID : {$offer['id']} </div> <div class='w3-col w3-quarter'> Source : {$offer['source']} </div> <div class='w3-col w3-half'> <b>Total Price : {$offer['price']['total']} {$offer['price']['currency']}</b> </div> </div> <table class='w3-table w3-bordered'> <tr class='w3-indigo'> <th>Segment</th> <th>Flight No</th> <th>Departure Time</th> <th>Arrival Time</th> </tr> "; foreach ($offer['itineraries']as $itins) { foreach ($itins['segments'] as $segment) { $html .= segmentRow($segment); } } $html .= "</table>\n<br>"; foreach ($offer['travelerPricings'] as $k => $tp) { $n = $k + 1; $html .= "Traveller $n : {$tp['travelerType']}<br> Amount : {$tp['price']['total']} {$tp['price']['currency']}<br><br> "; } return $html; } function segmentRow($segment) { $dt = (new DateTime($segment['departure']['at']))->format('Y-m-d H:i'); $at = (new DateTime($segment['arrival']['at']))->format('Y-m-d H:i'); $row = "<tr> <td>{$segment['departure']['iataCode']}-{$segment['arrival']['iataCode']}</td> <td>{$segment['carrierCode']} {$segment['number']}</td> <td>$dt</td> <td>$at</td> </tr> "; return $row; } ?> <!DOCTYPE=html> <html lang="en"> <head> <meta charset='utf-8'> <title>Flight Offers</title> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> </head> <body> <h1>Flight Offers</h1> <div class='w3-content'> <?= $html ?> </div> </body> </html> producing 5 offers like this ...
  8. What have you tried and where are you having a problem?
  9. The end of the string that you just posted contained stuff that shouldn't be there in the json data . . . ,"carriers":{"QR":"QATAR AIRWAYS","BA":"BRITISH AIRWAYS"}}}Array ( [0] => meta [1] => data [2] => dictionaries // JavaScript Document ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Once I removed the offending text, it decoded without error. BTW, for future reference when using print_r(), put it inside <pre>..</pre> tags to get readable structured output. For example $array = json_decode($json, true); echo '<pre>' . print_r($array, 1) . '</pre>';
  10. Unfortunately, it isn't. On calling json_decode() it gives Are you sure you you posted the entire output?
  11. Just echo $requests_response->body; and post the resulting string output.
  12. print_r() results aren't processable. Can you post the json data that you have in $objects? $requests_response->body
  13. Have you read @kicken's posts? He's told you what's wrong and what you need to do. The bigger problem for me is that given a CSV record with one test score value and a table (spreadsheet!) with 9 test score value columns, how do you know which of the 9 to update?
  14. That will only select one record (g1/s1 or g1/s2) so you will only insert one new record
  15. This will list download links for all the .log files in specified directory that have the specified filectime $search_dir = 'c:/path/to/logs'; $search_date = '2023-01-03'; $files = glob("$search_dir/*.log"); // find all .log file in search dir $todays = array_filter($files, fn($v)=>date('Y-m-d',filectime($v))==$search_date); // filter for date's files only $names = array_map('basename', $todays); // remove paths for display if ($todays) { foreach ($todays as $k => $fn) { echo "<a href='$fn' download>$names[$k]</a><br>"; } } else echo "No files found"; You might be better off using filemtime() if looking for the date's log entries.
  16. Based on the sample output that you posted, you are short of a couple of tables student assessment scores teachers' remarks.
  17. sleep() , perchance to dream.
  18. I ran your query (cleaning the SELECT clause up to remove duplicate output) SELECT s.id as sid, gamedate, s.home_id, s.away_id, (CASE WHEN h.toggle = 1 THEN concat(h.city,' ',h.school) WHEN h.toggle IS NULL THEN h.school ELSE concat(h.school,' (',h.toggle,')') END) as home, (CASE WHEN a.toggle = 1 THEN concat(a.city,' ',a.school) WHEN a.toggle IS NULL THEN a.school ELSE concat(a.school,' (',a.toggle,')') END) as away FROM a_schedule s JOIN a_schools h ON h.id = s.home_id JOIN a_schools a ON a.id = s.away_id; on this data a_schools a_schedule +----+-----------+--------+---------+ +----+------------+----------+---------+---------+ | id | school | toggle | city | | id | gamedate | gametime | home_id | away_id | +----+-----------+--------+---------+ +----+------------+----------+---------+---------+ | 1 | School 1 | 1 | City 1 | | 1 | 2023-01-04 | 19:30:00 | 1 | 2 | | 2 | School 2 | NULL | City 2 | | 2 | 2023-01-11 | 19:30:00 | 10 | 11 | | 3 | School 3 | NULL | City 3 | | 3 | 2023-01-18 | 19:30:00 | 15 | 3 | | 4 | School 4 | NULL | City 4 | | 4 | 2023-01-25 | 19:30:00 | 4 | 5 | | 5 | School 5 | 2 | City 5 | | 5 | 2023-02-01 | 19:30:00 | 6 | 7 | | 6 | School 6 | NULL | City 6 | | 6 | 2023-02-08 | 19:30:00 | 8 | 9 | | 7 | School 7 | NULL | City 7 | +----+------------+----------+---------+---------+ | 8 | School 8 | NULL | City 8 | | 9 | School 9 | NULL | City 9 | | 10 | School 10 | 1 | City 10 | | 11 | School 11 | NULL | City 11 | | 12 | School 12 | NULL | City 12 | | 13 | School 13 | NULL | City 13 | | 14 | School 14 | NULL | City 14 | | 15 | School 15 | 2 | City 15 | | 16 | School 16 | NULL | City 16 | +----+-----------+--------+---------+ and got this +-----+------------+---------+---------+-------------------+--------------+ | sid | gamedate | home_id | away_id | home | away | +-----+------------+---------+---------+-------------------+--------------+ | 1 | 2023-01-04 | 1 | 2 | City 1 School 1 | School 2 | | 2 | 2023-01-11 | 10 | 11 | City 10 School 10 | School 11 | | 3 | 2023-01-18 | 15 | 3 | School 15 (2) | School 3 | | 4 | 2023-01-25 | 4 | 5 | School 4 | School 5 (2) | | 5 | 2023-02-01 | 6 | 7 | School 6 | School 7 | | 6 | 2023-02-08 | 8 | 9 | School 8 | School 9 | +-----+------------+---------+---------+-------------------+--------------+
  19. $data = '{"location":{"name":"London","region":"City of London, Greater London","country":"United Kingdom","lat":51.52,"lon":-0.11,"tz_id":"Europe/London","localtime_epoch":1672618641,"localtime":"2023-01-02 0:17"},"current":{"last_updated_epoch":1672618500,"last_updated":"2023-01-02 00:15","temp_c":8.0,"temp_f":46.4,"is_day":0,"condition":{"text":"Light rain","icon":"//cdn.weatherapi.com/weather/64x64/night/296.png","code":1183},"wind_mph":4.3,"wind_kph":6.8,"wind_degree":220,"wind_dir":"SW","pressure_mb":1009.0,"pressure_in":29.8,"precip_mm":0.0,"precip_in":0.0,"humidity":93,"cloud":25,"feelslike_c":7.0,"feelslike_f":44.7,"vis_km":10.0,"vis_miles":6.0,"uv":1.0,"gust_mph":5.8,"gust_kph":9.4}}'; $characters = json_decode($data, 1); // decode the JSON feed as array echo $characters['location']['name'] . '<br>'; echo $characters['current']['condition']['text'] . '<br>'; echo $characters['current']['condition']['code'] . '<br>'; If you want to stay with objects... $data = '{"location":{"name":"London","region":"City of London, Greater London","country":"United Kingdom","lat":51.52,"lon":-0.11,"tz_id":"Europe/London","localtime_epoch":1672618641,"localtime":"2023-01-02 0:17"},"current":{"last_updated_epoch":1672618500,"last_updated":"2023-01-02 00:15","temp_c":8.0,"temp_f":46.4,"is_day":0,"condition":{"text":"Light rain","icon":"//cdn.weatherapi.com/weather/64x64/night/296.png","code":1183},"wind_mph":4.3,"wind_kph":6.8,"wind_degree":220,"wind_dir":"SW","pressure_mb":1009.0,"pressure_in":29.8,"precip_mm":0.0,"precip_in":0.0,"humidity":93,"cloud":25,"feelslike_c":7.0,"feelslike_f":44.7,"vis_km":10.0,"vis_miles":6.0,"uv":1.0,"gust_mph":5.8,"gust_kph":9.4}}'; $obj = json_decode($data); // decode the JSON feed as object echo $obj->location->name . '<br>'; echo $obj->current->condition->text . '<br>'; echo "<img src='{$obj->current->condition->icon}'>" . '<br>'; echo $obj->current->condition->code . '<br>';
  20. We aren't psychic. Code? Sample log file names?
  21. What have you tried so far?
  22. In your first code block you read each object putting the name in to the same variabe, thus each one overwrites the previous. Probably, if the last object is empty, or the name is empty, nothing will print. In the second block you echo each name as it is read. Without seeing the content of $data or $characters then cannot be sure.
  23. PHP code must be in a .php file to be executed (with a standard configuration) However a .php file does not need to contain any php code, it can be html only. So any html you can do in an .html file should work in a .php file. Define the background image in your css - it should work the same in either.
  24. The id of an element must be unique, so change those id="name" to class="name" data attributes are useful. Give each pair of fields the same data-id value. (Easier than parsing names) For example <!DOCTYPE=html> <html lang="en"> <head> <meta charset='utf-8'> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script type='text/javascript'> $(function() { $(".weekday").click( function() { let id = $(this).data("id") // get data-id value of checkbox let time = $(".name[data-id="+id+"]") // find timing inut with same data-id value if ($(this).is(":checked")) { $(time).focus() } else { $(time).val("") } }) }) </script> </head> <body> <input name="weekday[8]" type="checkbox" value="21" class="weekday" checked data-id="8"> Monday <br> Timing <input name="timing[8]" type="text" class="name" value="11" size="45" data-id="8"> <br><br> <input name="weekday[9]" type="checkbox" value="99" class="weekday" data-id="9"> Tuesday <br> Timing <input name="timing[9]" type="text" class="name" value="" size="45" data-id="9"> <br><br> <input name="weekday[10]" type="checkbox" value="77" class="weekday" data-id="10"> Wednesday <br> Timing <input name="timing[10]" type="text" class="name" value="" size="45" data-id="10"> </body> </html>
  25. Here's my take on your problem <!DOCTYPE=html> <html lang="en"> <head> <meta charset='utf-8'> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script type='text/javascript'> function btnclick(thebtn) { if ($(thebtn).html() == "+") { $(thebtn).html("-") addrow() } else { delrow(thebtn) } } function delrow(thebtn) { $(thebtn).parent().parent().remove() } function addrow() { let r = $("<tr>") let b = $("<span>", {"html":"+", "onclick":"btnclick(this)", "class":"bttn w3-button w3-light-gray"}); let td1 = $("<td>", {"class":"ca"}) let td2 = $("<td>") let td3 = $("<td>") let td4 = $("<td>") let i1 = $("<input>", {"name":"name[]", "type":"text"}) let i2 = $("<input>", {"name":"val1[]", "type":"number"}) let i3 = $("<input>", {"name":"val2[]", "type":"number"}) $(td1).html(b) $(td2).html(i1) $(td3).html(i2) $(td4).html(i3) $(r).append(td1).append(td2).append(td3).append(td4) $("#rows").append(r) } </script> <style type='text/css'> table { border-collapse: collapse; width: 600px; } td, th { padding: 4px; } .ca { text-align: center; } </style> </head> <body> <header class='w3-container w3-padding'> <h1>Example</h1> </header> <form> <table border='1'> <tr> <th>Action</th> <th>Name</th> <th>Val 1</th> <th>Val 2</th> </tr> <tbody id='rows'> <tr> <td class='ca'><span class='bttn w3-button w3-light-gray' onclick='btnclick(this)'>+</span></td> <td><input type='text' name='name[]' ></td> <td><input type='number' name='val1[]' ></td> <td><input type='number' name='val2[]' ></td> </tr> </tbody> </table> <input type="submit"> </form> </body> </html>
×
×
  • 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.