-
Posts
24,602 -
Joined
-
Last visited
-
Days Won
830
Everything posted by Barand
-
Adding elements from one multidimensional array to another
Barand replied to kenoli's topic in PHP Coding Help
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. -
Primary keys are unique identifiers for each entity and therefore, by definition, are already UNIQUE. (Or did you really mean monkeys? 🙂 )
-
You send and receive the array OK. That just leaves your processing of it inside the function.
-
What's your code that calls generateSurveyItem() ?
-
Adding elements from one multidimensional array to another
Barand replied to kenoli's topic in PHP Coding Help
Which particular bit of your code is giving you a problem? -
Reordering columns in phpmyadmin and keeping them in that order?
Barand replied to the_toolman's topic in MySQL Help
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. -
Reordering columns in phpmyadmin and keeping them in that order?
Barand replied to the_toolman's topic in MySQL Help
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. -
How to handle json respond from api endpoint (Uncaught TypeError: )
Barand replied to charlion's topic in PHP Coding Help
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) -
How to handle json respond from api endpoint (Uncaught TypeError: )
Barand replied to charlion's topic in PHP Coding Help
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 -
Barebones PHP to add a contact email form upload file provision
Barand replied to boilermaker73's topic in PHP Coding Help
https://www.php.net/manual/en/features.file-upload.post-method.php -
https://www.php.net/manual/en/language.types.string.php
-
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.
-
Search for string in column in mysql table separated by a character
Barand replied to jigga's topic in PHP Coding Help
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 | +------------------+ -
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.
-
Don't put quotes around placeholders And "LIKE" without widcards is a wast of time
-
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.
-
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)
-
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.
-
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.
-
Example of AJAX call to same page
-
You will need INNER JOIN LEFT JOIN GROUP BY GROUP_CONCAT There's a link to SQL tutorials in my sig that might help.