-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
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 | +-------+---------------------+
-
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
-
using array_replace on a 2 dimensional array
Barand replied to webdeveloper123's topic in PHP Coding Help
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); -
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
-
What possessed you you to store data in a database like that?
-
using array_replace on a 2 dimensional array
Barand replied to webdeveloper123's topic in PHP Coding Help
With similar... $new = [ 1 => ['age' => 33], 5 => ['fname' => 'Sandra'], 3 => ['lname' => 'Cunningham'] ]; $table = array_replace_recursive($table, $new); Original $table $new resulting $table -
using array_replace on a 2 dimensional array
Barand replied to webdeveloper123's topic in PHP Coding Help
IMHO PHP arrays are a powerfulr feature of the language and one should learn to use them and the associated array functions. -
If you couldn't be bothered to study, even though it was to your advantage, why should I be bothered to help?
-
using array_replace on a 2 dimensional array
Barand replied to webdeveloper123's topic in PHP Coding Help
$table[1]['age'] = 33; $table[5]['fname'] = 'Sandra'; $table[3]['lname'] = 'Cunningham'; -
Show us what you have tried already and tell us which bit you are having a problem with. Then maybe we can help.
-
Do you have a specific problem with some aspect of your code?
-
using array_replace on a 2 dimensional array
Barand replied to webdeveloper123's topic in PHP Coding Help
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. -
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)
-
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.
-
If it's coming from the link's querystring you should be using $_GET['did_ivr_disable']
-
<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?
-
$total_price = array_sum($cart['PRICE']); echo "₦ $total_price"; Gives something like Use FontAwesome or similar for the cart icon.
-
As you show a currency symbol, are you sure you don't want the total price?
-
Does this do it? Total_qty = array_sum($cart['QUANTITY']);
-
Use the <> button in the toolbar when posting code. I have done it for you - this time.