Jump to content

Barand

Moderators
  • Posts

    24,602
  • Joined

  • Last visited

  • Days Won

    830

Everything posted by Barand

  1. That is NOT a facsimile of your titles array. Your $titles array has keys of "title", "medium" etc. That array above has values of "title", medium" etc with numeric keys. Use print_r(array) on both to seee the difference.
  2. Primary keys are unique identifiers for each entity and therefore, by definition, are already UNIQUE. (Or did you really mean monkeys? 🙂 )
  3. You send and receive the array OK. That just leaves your processing of it inside the function.
  4. What's your code that calls generateSurveyItem() ?
  5. It doesn't like anything less than 0 as an offset value in the LIMIT clause.
  6. On line 601 you set $page to "" (empty string) You only set it to an int value if $_GET['page'] is set. (603) Change 601 to $page = 0;
  7. Which particular bit of your code is giving you a problem?
  8. No, but it it gives you a way of viewing the data in order you want. To make it permanent you woud have to ALTER the table or create a view with required order and use that instead of the table.
  9. My theory bites the dust then. I thought it might be a string.
  10. original table Query... ALTER TABLE `test`.`user_demo` CHANGE COLUMN `username` `username` VARCHAR(20) NULL DEFAULT NULL AFTER `userid`; new table [EDIT....] There are a couple of alternatives. 1 ) Use a query to specify the required column sequence SELECT fname , lname , username , userid FROM test.user_demo; 2 ) Create a "view" on the table with the required column sequence.
  11. try <html> <head> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> <script type='text/javascript'> $().ready( function() { var burl = "https://api3.binance.com"; /////////// baseurl///////// var query = burl + '/api/v3/aggTrades'; $.get( query, {"symbol":"BTCUSDT"} , function(resp) { $("#demo").html("a - " + resp[0].a + "<br>") $("#demo").append("p - " + resp[0].p + "<br>") $("#demo").append("q - " + resp[0].q + "<br>") var d = new Date() d.setTime(resp[0].T) $("#demo").append("T - " + d.toString()) }, "JSON" ) }) </script> </head> <body> <div id='demo'> <!--output goes here--> </div> </body> </html> outputs... a - 577817177 p - 48585.69000000 q - 0.10000000 T - Mon Feb 15 2021 17:50:19 GMT+0000 (GMT Standard Time)
  12. You have an array containing an object. Array ( [0] => stdClass Object ( [a] => 26129 [p] => 0.01633102 [q] => 4.70443515 [f] => 27781 [l] => 27781 [T] => 1498793709153 [m] => 1 [M] => 1 ) ) Try innerHTML = obj[0].p
  13. https://www.php.net/manual/en/features.file-upload.post-method.php
  14. https://www.php.net/manual/en/language.types.string.php
  15. Your query string is in single quotes therefore $table is not interpreted as "users". Why are you putting the table name in a variable? It's often a sympton of a poorly designed database if it is necessary.
  16. Don't. Put your oemnr in a separate table, one per row with the id of the parent record as a foreign key. In other words, normalize your data. +------------------+ | main_table | +------------------+ +------------------+ | id (PK) |-------+ | oem_number | | etc... | | +------------------+ +------------------+ | | id (PK) | +------<| table_id (FK) | | oemnr | +------------------+
  17. Your problem is that whatever that mess of code is doing takes more than 2 minutes to execute. You need to find which bit is taking too long to execute and fix. When you post code here, use the code button "<>" in the toolbar. Hopefully that may give readable code (with line breaks and indents). No one is going to attempt to read that.
  18. Don't put quotes around placeholders And "LIKE" without widcards is a wast of time
  19. If that is how you want the output then GROUP BY may well be the answer student data... +-------+-----------+----------+ | regno | firstname | lastname | +-------+-----------+----------+ | 9738 | Jane | Jenkins | | 9844 | Janet | Gordon | | 9966 | Liz | Lyle | | 9978 | Olivia | Unwin | | 9979 | Curly | NULL | | 9980 | NULL | Larry | | 9981 | NULL | Mo | | 9982 | Fred | | | 9983 | Emily | NULL | +-------+-----------+----------+ query... SELECT CASE WHEN IFNULL(firstname, '') = '' THEN 'No first name' WHEN IFNULL(lastname, '') = '' THEN 'No last name' ELSE 'OK' END as category , COUNT(*) as Errors , GROUP_CONCAT(regno SEPARATOR ', ') as IDs FROM student GROUP BY category HAVING category <> 'OK'; results... +---------------+--------+------------------+ | category | Errors | IDs | +---------------+--------+------------------+ | No first name | 2 | 9980, 9981 | | No last name | 3 | 9983, 9979, 9982 | +---------------+--------+------------------+ CAUTION: the default maximum length of GROUP_CONCAT item is 1024 characters so in my example I would only get a max of 170 ids listed.
  20. My way the two scripts would be identical except the US one connects locally to the mysql server and the UK one connects remotely. (If the US DB server is not local to the US page then both would connect using the DB server's IP address)
  21. UK Script - downloads from local UK file server and DB connection is to (remote) US DB server US Script - downloads from local US file server and DB connection is to (local) US DB server.
  22. In a database the case sensitivity of a field depends on which collation you apply to that field. If the collation name ends with "ci" it is case insensitive. The default collation would normally be case-insensitive but changed for fields where you specifically need sensitivity. I personally would count "fred" and "frEd" as the same username. You wouldn't be storing passwords as plain text for searching anyway.
  23. Example of AJAX call to same page
  24. You will need INNER JOIN LEFT JOIN GROUP BY GROUP_CONCAT There's a link to SQL tutorials in my sig that might help.
×
×
  • 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.