Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. Always store in the correct format (yyyy-mm-dd hh:ii:ss). Retrieval is flexible... mysql> SELECT name, submitted FROM test WHERE submitted BETWEEN '2022-05-05 09:05:00' AND '2022-05-05 13:30:00'; +-------+---------------------+ | name | submitted | +-------+---------------------+ | Curly | 2022-05-05 10:46:30 | | Larry | 2022-05-05 12:20:30 | +-------+---------------------+ mysql> SELECT name, submitted FROM test WHERE submitted BETWEEN '20220505090500' AND '20220505133000'; +-------+---------------------+ | name | submitted | +-------+---------------------+ | Curly | 2022-05-05 10:46:30 | | Larry | 2022-05-05 12:20:30 | +-------+---------------------+ mysql> SELECT name, submitted FROM test WHERE DATE(submitted) = '2022-05-05' AND TIME(submitted) BETWEEN '09:05:00' AND '13:30:00'; +-------+---------------------+ | name | submitted | +-------+---------------------+ | Curly | 2022-05-05 10:46:30 | | Larry | 2022-05-05 12:20:30 | +-------+---------------------+ mysql> SELECT name, submitted FROM test WHERE DATE(submitted) = '20220505' AND TIME(submitted) BETWEEN '090500' AND '133000'; +-------+---------------------+ | name | submitted | +-------+---------------------+ | Curly | 2022-05-05 10:46:30 | | Larry | 2022-05-05 12:20:30 | +-------+---------------------+
  2. Too pictorial, didn't read. But if you were too explain how I can load those images into my code editor to check your code....
  3. My original should also have checked for no more 's' chars. $str = 'S0100111W 00000010 sS0100111R 11101011-sS0100111W 00000010 11101111 sS0100111W 00000010 sS0100111R 11101111-sS0100111W 00000010 11111111 sS0100111W 00000011 sS0100111R 10111100-sS0100111W 00000011 10111101 sS0100111W 00000011 sS0100111R 10111101-sS0100111'; $p1 = $p2 = 0; while (($p1 = strpos($str, 'S', $p2)) !== false) { $p2 = strpos($str, 's', $p1); if ($p2===false) { // add this check $p2 = strlen($str); } echo substr($str, $p1, $p2-$p1+1) . '<br>'; } giving S0100111W 00000010 s S0100111R 11101011-s S0100111W 00000010 11101111 s S0100111W 00000010 s S0100111R 11101111-s S0100111W 00000010 11111111 s S0100111W 00000011 s S0100111R 10111100-s S0100111W 00000011 10111101 s S0100111W 00000011 s S0100111R 10111101-s S0100111
  4. You were close but your arrays were incorrectly defined. This works too $table = array_merge($table, $newdata); $array1 = array( 1 => ['age' => 33] ); $array5 = array( 5 => ['fname' => 'Sandra'] ); $array3 = array( 3 => ['lname' => 'Cunningham'] ); $table2 = array_replace_recursive($table, $array1, $array5, $array3);
  5. Try $str = 'S1234567 1234567s S1234567 1234567s S1234567 1234567s S1234567 1234567s'; $p1 = $p2 = 0; while (($p1 = strpos($str, 'S', $p2)) !== false) { $p2 = strpos($str, 's', $p1); echo substr($str, $p1, $p2-$p1+1) . '<br>'; } giving S1234567 1234567s S1234567 1234567s S1234567 1234567s S1234567 1234567s
  6. Thanks for the pictures - I'll hang them on my lavatory wall. It's all they are useful for.
  7. What possessed you you to store data in a database like that?
  8. With similar... $new = [ 1 => ['age' => 33], 5 => ['fname' => 'Sandra'], 3 => ['lname' => 'Cunningham'] ]; $table = array_replace_recursive($table, $new); Original $table $new resulting $table
  9. IMHO PHP arrays are a powerfulr feature of the language and one should learn to use them and the associated array functions.
  10. If you couldn't be bothered to study, even though it was to your advantage, why should I be bothered to help?
  11. $table[1]['age'] = 33; $table[5]['fname'] = 'Sandra'; $table[3]['lname'] = 'Cunningham';
  12. Show us what you have tried already and tell us which bit you are having a problem with. Then maybe we can help.
  13. Do you have a specific problem with some aspect of your code?
  14. Can anyone help with what? You've shown us a lot of things weren't what you wanted (even they they do what the manual says they do). How about telling what result you do want.
  15. The clue is in the message. Read and do as it says.
  16. Search result:
  17. Define the time submitted as submitted DATETIME NOT NULL DEFAULT current_timestamp That will automatically enter the time when you add a record. For example mysql> create table test (name varchar(20), submitted DATETIME NOT NULL DEFAULT current_timestamp ); Query OK, 0 rows affected (0.40 sec) mysql> insert INTO test (name) VALUES ('Curly'); Query OK, 1 row affected (0.06 sec) mysql> insert INTO test (name) VALUES ('Larry'); Query OK, 1 row affected (0.05 sec) mysql> insert INTO test (name) VALUES ('Mo'); Query OK, 1 row affected (0.04 sec) mysql> select * from test; +-------+---------------------+ | name | submitted | +-------+---------------------+ | Curly | 2022-05-06 21:18:40 | | Larry | 2022-05-06 21:19:11 | | Mo | 2022-05-06 21:19:25 | +-------+---------------------+ 3 rows in set (0.00 sec)
  18. You need to turn the mysql error reporting. Your function's query gets 3 result columns and binds ony 2 of them. Also the over number and ballinover values will be meaningless in that query as it uses an aggregation function.
  19. If it's coming from the link's querystring you should be using $_GET['did_ivr_disable']
  20. <input value="<?php echo $item['did_ivr_disable'] == (0) ? 'Disabled' : 'Enabled' ?>" type="text" That line contains the only occurence of $item that I can find in your code - so where is it getting a value?
  21. $total_price = array_sum($cart['PRICE']); echo "&#8358; $total_price"; Gives something like Use FontAwesome or similar for the cart icon.
  22. As you show a currency symbol, are you sure you don't want the total price?
  23. Does this do it? Total_qty = array_sum($cart['QUANTITY']);
  24. Use the <> button in the toolbar when posting code. I have done it for you - this time.
×
×
  • 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.