Jump to content

Barand

Moderators
  • Content Count

    21,642
  • Joined

  • Last visited

  • Days Won

    564

Everything posted by Barand

  1. Here's sample code I wrote a few years back. DATA mysql> select * from category; +----+-----------+--------+ | id | service | parent | +----+-----------+--------+ | 1 | Cat 1 | 0 | | 2 | Cat 2 | 0 | | 3 | Cat 3 | 0 | | 4 | Cat 1 1 | 1 | | 5 | Cat 1 2 | 1 | | 6 | Cat 2 1 | 2 | | 7 | Cat 2 2 | 2 | | 8 | Cat 2 3 | 2 | | 9 | Cat 3 1 | 3 | | 10 | Cat 1 1 1 | 4 | | 11 | Cat 1 1 2 | 4 | | 12 | Cat 2 3 1 | 8 | +----+-----------+--------+ OUTPUT CODE <?php $sql = "SELECT
  2. microtime() without an argument returns a weird string format (eg "0.94624300 1620376872" ) that is not a valid number. Use microtime(true) to get a numeric value (eg 1620377011.4593). See https://www.php.net/microtime
  3. One problem you will have is that for any offset there are usually several possible names. For your "+05:30" example there are only two but as the array below shows, there are usualy quite a few more ... $timezones = array ( '+00:00' => array ( 0 => 'Africa/Abidjan', 1 => 'Africa/Accra', 2 => 'Africa/Bamako', 3 => 'Africa/Banjul', 4 => 'Africa/Bissau', 5 => 'Africa/Casablanca', 6 => 'Africa/Conakry', 7 => 'Africa/Dakar', 8 => 'Africa/El_Aaiun', 9 => 'Africa/Freetown', 10 => 'Africa/Lome', 11 => 'Afr
  4. It is a "Windows feature" that just needs turning on.
  5. I'm using IIS on Windows 10 Home. AFAIK, it just need kicking into life using IIS Manager.
  6. If you have Windows, IIS should already be installed.
  7. Depends the structure you want for your array. Using your existing query... $res = $pdo->query("SELECT i.title_eng as title , d.content_eng as content FROM tb_helpinfo i INNER JOIN tb_helpdetail d ON i.id = d.helpinfo_id ORDER BY title "); ## METHOD 1 $data = []; foreach ($res as $r) { if (!isset($data[$r['title']])) { $data[$r['title']] = []; } $data[$r['title']][] = $r['content']; } echo '<pre> Method 1 ', print_r($da
  8. Did you just want to advertise the results of your efforts or do you actually have a question?
  9. "password" is a keyword (and, I agree, best avoided) but is not a reserved word requiring backticks. @Kausalya use password_hash() and password_verify() when storing and checking passwords.
  10. Check the column definition in your table. If you make it UNSIGNED you can double that value, which will take you to the year 2106. echo date('Y-m-d', 4294967294); // 2106-02-07 Better still, use date or DATE/DATETIME fields for dates - that's what they're there for.
  11. I suggest you turn on error reporting in your php.ini file.
  12. Can you tell us what you are trying to achieve? It's impossible to tell from that hotchpotch of code.
  13. What does your function arary_multisort() do? Are you wanting something like this (sorting them in the query) ... $res = $conn->query("SELECT option_id , id FROM bets WHERE win_status = '1' AND updated_at BETWEEN '2021-05-01 13:00:00.000000' AND '2021-05-02 08:00:00.000000' ORDER BY option_id, id "); $info = []; foreach ($res as $row) { $info[$row['option_id']][] = $row['id']; } echo '<pre>', print_r($in
  14. Depends on the column definition for your date/time column (DATETIME or TIMESTAMP) From the manual ... The limit of a timestamp is the maximum value of a signed integer, mysql> SELECT from_unixtime(2147483647); +---------------------------+ | from_unixtime(2147483647) | +---------------------------+ | 2038-01-19 03:14:07 | +---------------------------+ When storing dates and times in a database, use DATETIME, TIMESTAMP, DATE or TIME types. As well as DATE AND DATETIME having a greater date range, they are infinitely more readable for mere humans.
  15. I ran your code and it functions OK. The only way I can see that $result is not defined is if $_GET['id'] is empty or not an integer. But you say that you are inputting a valid id value so I'm out of guesses. Good luck.
  16. Have you got PDO and PHP error reporting options set?
  17. Do you still get that notice if you enter a valid id?
  18. Instead of using hyphens, use array indices in your form input field names <input type="text" name="guestname[0]" > <input type="text" name="guestname[1]" >
  19. If you use an aggregation function (SUM, COUNT, AVG etc) without a GROUP BY clause you get a single aggregation (row) for the whole table. Don't use "SELECT * ", especially with aggregations. Don't run queries inside loops. Get the data you need with a single query Don't litter the forum with multiple threads on the same topic. From your earlier post it looked like you want the average daily total for each month SELECT YEAR(day) as yr , MONTH(day) as mth , AVG(price) as avprice FROM ( SELECT DATE(order_da
  20. See https://www.php.net/manual/en/language.variables.external.php
  21. DOH! 🙄 Forgot to include the flat charge in the spreadsheet total formula (copied the "Units" total formula) and also completely missed the VAT element. Thus demonstrating the perils of copy/paste - a warning to all.
×
×
  • 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.