Jump to content

Barand

Moderators
  • Posts

    24,606
  • Joined

  • Last visited

  • Days Won

    831

Everything posted by Barand

  1. No "old farts" that I am aware of.
  2. Possibly. How can I know? Syntax is OK.
  3. You'll find that serializing data it not used very much these days, largely abandoned in favour of JSON data $data = [ 'count' => 1, 'total' => 5, 'average' => 5 ]; echo "Serialized: " . serialize($data); echo "JSON: " . json_encode($data);; gives Serialized: a:3:{s:5:"count";i:1;s:5:"total";i:5;s:7:"average";i:5;} JSON: {"count":1,"total":5,"average":5}
  4. So just, for example, "SELECT id,name, email FROM ..." so you only retrieve what you need. That's why you shouldn't use "SELECT * " in queries as that retrieves every column, need it or not, and slow your queries. [EDIT] PS That's one of the reasons not to use SELECT *.
  5. It seems reasonable to me, given the initial caveat.
  6. You say all but only select a single item. And you don't have a submit button! Where is the $iditemm value coming from? No idea - where is it supposed to come from?
  7. while (($p1 = strpos($str, 'S', $p2)) !== false) { // while there is a next 'S', get its position $p2 = strpos($str, 's', $p1); // find position of following 's' if ($p2===false) { // if there is no following 's' $p2 = strlen($str); // assume its position is the end of the string } echo substr($str, $p1, $p2-$p1+1) . '<br>'; // echo the characters between the S and s }
  8. Store the test dates - that will tell you who got there first.
  9. You'll affect performance more, and complicate the queries, by splitting your users across more than one table. It would also break a rule of DB design - don't store derived data
  10. +-----------+ | user | +-----------+ | user_id |--------+ | name | | | email | | +-----------------+ | phone | | | answer | +-----------+ | +-----------------+ | | answer_id | +----0<| user_id | | question_no | | selected_choice | +-----------------+ One user table. Query to find which answered 4 questions SELECT u.user_id , u.name FROM user u JOIN answer a USING (user_id) GROUP BY u.user_id HAVING COUNT(answer_id) = 4
  11. Is there any chance that you might answer that question sometime soon? (At my age an fear I am running out of the time needed to get you thinking about what your code is doing)
  12. There is an absence of DB query code in anything you have posted and you have not explicitly stated the origin of all those values that you are passing in the query string ($_GET data), so here is my guess... Does $_GET['did_ivr_disable'] contain the value from the database that you need? Or have you not thought about it?
  13. If you always set it to zero, what other result do expect? I did say that it should be the value from your DB.
  14. I'm equally sorry that we are new to telepathic communication and so have no idea what your code is that is giving the result below. Did you implement the method I showed you?
  15. That must be annoying.
  16. Exactly. As I said, determine which button needs to be shown as selected if the value in the database is 0, then the 0 button needs to be "checked". if the value in the database is 1, then the 1 button needs to be "checked". Example $currentValue = 0; // from DB $chk0 = $currentValue==0 ? 'checked="checked"' : ''; $chk1 = $currentValue==1 ? 'checked="checked"' : ''; echo "<input type='radio' name='myradio' value='0' $chk0> No &emsp; <input type='radio' name='myradio' value='1' $chk1> Yes";
  17. Determine which button needs to be shown as selected and set its "checked" attribute
  18. 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 | +-------+---------------------+
  19. 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....
  20. 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
  21. 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);
  22. 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
  23. Thanks for the pictures - I'll hang them on my lavatory wall. It's all they are useful for.
  24. What possessed you you to store data in a database like that?
×
×
  • 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.