Posts by Marcelo de Andrade • 7,261 points
255 posts
-
5
votes1
answer117
viewsQ: How to use a variable in the array_walk?
I’m trying a solution without going through "manually"(foreach) an array, to add in the subarrays, a new pair of chave => valor. With the array_walk I can invoke a callback and treat the array…
-
3
votes1
answer50
viewsQ: How is GMAP API requests accounted for?
In an internal system, there is a simple plot of a route A - B on one of the pages. Recently this page is receiving a larger number of requests and consequently ordering Gmap more times. I want to…
-
1
votes1
answer812
viewsQ: How to use CASE WHEN in an IN statement?
In a query I am gathering data on representatives, customers and sellers. Some representatives have sellers, who in turn have customers. These cases are exceptional as clients are directly linked to…
-
0
votes3
answers756
viewsA: How to remove duplicate data in this query?
Using the clause ROW_NUMBER next to OVER you can do it this way: SELECT * FROM ( select products.id as product_id, offers.id as offer_id, companies.id as company_id, products.title,…
-
0
votes2
answers1207
viewsA: Consultation of Secured Transaction
The text you are receiving is nothing more than the XML return. To work with you PHP, you must effect the parse with simplexml_load_string: <?php $xml = <<<XML <?xml version="1.0"…
-
3
votes2
answers1494
viewsQ: How to get the first result of duplicate lines?
Situation: In a table there is a list of items with their respective values invoiced in invoice. This table has a single field that varies according to the insertion of the data, can repeat all…
sql-serverasked Marcelo de Andrade 7,261 -
1
votes2
answers86
viewsA: PHP wrapper wmic
Doing the combination of functions str_replace, explode and array_combine we can do it this way: $output = <<<OUTPUT CLASS: Win32_Process…
-
1
votes1
answer194
viewsQ: How to delimit a string field for use in the IN clause
In the tabela_A own a field cod_canal where is a INT, in tabela_B own a field canais of the string type and separating the codes by ,. Example: 1,3,6,9,12. On a first attempt, I just thought I’d…
sql-serverasked Marcelo de Andrade 7,261 -
0
votes2
answers45
viewsA: Fine-tuning a search with Analytics API + PHP
The message "Unknown metric" is displayed because ga:keyword is a dimension, not a metric. Try the query as follows: $analytics->data_ga->get( 'ga:xxxxxx', '7daysAgo', 'today',…
-
5
votes3
answers343
viewsA: How to check if the timestamp is today?
Just compare the date by formatting it with date: if(date('d/m/y') == date('d/m/y', strtotime('Aug 22, 2016 10:24 AM'))) { echo "É hoje!"; // Ludmilla curtiu }…
-
0
votes1
answer82
viewsA: Dynamic php css
Since you’re doing this manually, the only way I can see is for you to group the path in a grouping element g and assigning colors by groups: #grupo-1 path { fill: blue; } #grupo-2 path { fill: red;…
-
2
votes1
answer920
viewsQ: SUM and GROUP BY doubling values
While trying to add and group values, I found that the SUM and GROUP BY are not behaving the way I hope and could not identify the cause. Making the query below SELECT…
-
8
votes4
answers1052
viewsA: How do we know the date is the last day of the month?
Another option would be to use the function cal_days_in_month which returns the number of days of the month and year reported: $days = cal_days_in_month(CAL_GREGORIAN, 8, 2016); // Retorna 31 echo…
-
4
votes3
answers1866
viewsA: How to Display Json in PHP
According to the documentation, you will receive a JSON like this: { "type": "contact.list", "total_count": 105, "contacts": [ { "type": "contact", "id": "530370b477ad7120001d", }, { "type":…
-
1
votes1
answer142
viewsQ: Negation operator returns value that should be discarded
When using the negation operator, I want to get only the part of the text that does not contain the previously denied group. Using the expression ( ?<br\/?> ?)(Unit.), I get the following…
regexasked Marcelo de Andrade 7,261 -
3
votes2
answers131
viewsA: Format date written "ex. January 12, 2017" to default (Y-m-d)
Using the function date_create_from_format you can format the date as you want but first you should make some changes: $string = "12 de Dezembro de 2017"; $string = preg_replace('/( de ){1,2}/', '…
-
4
votes2
answers171
viewsA: PDO error with variable in LIMIT
The error informs that one of the reported parameters has no value to be replaced. Let’s see: $perguntaQuiz = 2; $sql2 = $pdo->prepare('SELECT * FROM quiz_pergunta WHERE idquiz = :idQuiz ORDER BY…
-
7
votes3
answers16505
viewsA: How to get month and year of a date?
If your date field is of the type varchar, you need to convert it to format first date using the function STR_TO_DATE, then you can use the functions YEAR and MONTH : Combining the functions, it…
mysqlanswered Marcelo de Andrade 7,261 -
1
votes1
answer2207
viewsQ: Effect select with dynamic column
I have a consultation with N relationships, in one of these related tables I need to select a specific column that follows the pattern mes_valor, where mes is an abbreviation for one of the possible…
sql-serverasked Marcelo de Andrade 7,261 -
2
votes1
answer58
viewsA: Conveter PHP function for Javascript
Given the incomplete information, I assume you would like to verify inputs, below follows one and is almost identical to the PHP: function verificar() { var verificacao =…
-
2
votes1
answer667
viewsA: How to land % to integer on google Harts
Add to option the property pieSliceText : 'value' google.charts.load('current', { 'packages': ['corechart'] }); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data =…
-
1
votes1
answer151
viewsA: How to list mysqli data displaying in DESC but listing from top to bottom?
Just like the Bacchus already explained to you, you are using the bind_param incorrectly. This method passes a variable to the command SQL previously defined. If you "print" your query with method…
-
1
votes1
answer139
viewsQ: List the most liked posts
Using the Graph API Explorer with the call below: me?fields=posts{likes.summary(true).filter(stream)} I get my posts, who liked and a summary containing the total: { "posts": { "data": [{ "id":…
-
0
votes1
answer59
viewsA: Doubt to build Mysql query
Just like the dichrist commented, add the condition WHERE for the column flag_ativo: SELECT c.id AS id_campeonato, c.nome_camp AS nome_campeonato, p.nome_pais AS nome_pais FROM tb_campeonato c LEFT…
-
6
votes2
answers844
viewsA: Omit seconds in Mysql time field
Just as rray said, you have the following options DATE_FORMAT and TIME_FORMAT: DATE_FORMAT(NOW(), "%H:%i"); TIME_FORMAT(NOW(), "%H:%i"); I believe that in your case, TIME_FORMAT be more appropriate:…
mysqlanswered Marcelo de Andrade 7,261 -
1
votes1
answer245
viewsA: Send two parameters in a hred using classic Asp
On your link, you are accessing the recordset in two different ways: rsDados and Rsdados, also, your link is missing the concatenation & of querystring, change it to: <a…
-
16
votes4
answers1229
viewsQ: How do you know if a certain day is a weekend?
How to know if an informed day, of the current month, fell on the weekend? For example: echo isWeekend(24) // True echo isWeekend(26) // False In the related topic below, I can know today through…
-
2
votes1
answer40
viewsQ: Should I create a form for each row/record of that datatable?
In a hypothetical situation with a datatable, asynchronously will be made a swith of ativo/inativo for the record. I must create a form for each row/record of this datatable? Is it semantically…
htmlasked Marcelo de Andrade 7,261 -
1
votes2
answers2052
viewsA: How to create a single button to power on and off bulb for Arduino in html?
Using the Bootstrap together with the Bootstrap Toggle, can customize and leave with an appearance of a switch. For functionality, I will use AJAX to make the call to PHP: $(document).on('change',…
-
4
votes1
answer79
viewsA: Get Timezone from a date
If this date is returning as a string, you can use replace var str = "2016-02-22T14:55:00.000-03:00"; var timezone = str.substr(str.length - 6); console.log(timezone); If the date is in timestamp…
-
0
votes1
answer254
viewsA: Is it possible to analyze Instagram data (BI) via API?
Yes, the instagram has a API in which you can capture the data and work as you wish. Likes Followers Etc....…
-
0
votes2
answers591
viewsA: Send SMS by PHP
Using a repeat loop you would solve this problem as follows: foreach ($numbers as $number) { $result[] = $smsGateway->sendMessageToManyNumbers($number, $message, $deviceID, $options); } If there…
-
2
votes2
answers161
viewsQ: How to insert the elements of the X array into an index of the Y array?
I own the array y where in your index 0 holds the values App and Views array (size=1) 0 => array (size=2) 0 => string 'App' (length=3) 1 => string 'Views' (length=5) In the x I have a array…
-
4
votes4
answers1313
viewsQ: How to organize alphabetically a select obtained through a JSON?
I rode a select through the JSON below, the only problem is that it follows the order of the key, how to arrange it alphabetically? { "12": "Acre", "27": "Alagoas", "16": "Amapá", "13": "Amazonas",…
-
1
votes2
answers222
viewsA: Error with fetch_assoc, how do I correct? echo does not return desired value
To associate the entire query result, you must use the method fetch_all: $mysqli = new mysqli('localhost', 'root', '', 'mydb'); $sql = "SELECT * FROM ordem_producao WHERE op_id = $id;"; $query =…
phpanswered Marcelo de Andrade 7,261 -
0
votes1
answer103
viewsA: Variable debugging on the cake php layer
You can just give one var_dump($variavel), case within the Model or in the Controller move the variable to view, after the call of método: $this->set('result',…
-
1
votes3
answers418
viewsA: Is it possible to keep an object in a session variable?
For your situation I believe you should rethink the way your project is being developed, but answering your question: Yes, there is the possibility to keep an object saved. Read about the method…
-
0
votes3
answers2364
viewsQ: How to assign "Selected" to a dynamic option?
I’m populating a SELECT from a JSON received via AJAX as follows: $.each(parsedData, function(i, produto) { $('select#produtos').append(…
-
5
votes1
answer462
viewsA: How to solve the problem of PHP 5.6 with obsolete PPA on Linux?
The repository has changed as you can see in note. Add the add-apt-repository ppa:ondrej/php and update the apt-list: sudo apt-get update Then just install the desired version 5.5, 5.6, 7.0, 7.1:…
-
0
votes2
answers945
viewsQ: Compare values with different conditionals in the same table
When making a SELECT COUNT(*) in the view vwNotaFiscal I get the total of lines: 3498 SELECT COUNT(*) FROM dbo.vwNotaFiscal WHERE tbEmbarques_emissao BETWEEN CONVERT(DATE,'01/05/2016',103) AND…
-
0
votes2
answers961
viewsA: How to hide javascript API access data?
As @bfavaretto commented, there is no way to hide these credentials using the API in javascript. For this, use the server-side version of it.
-
2
votes1
answer91
viewsA: Installing Mysql on linux programmatically. How to set the password?
Change your .sh and add: echo "mysql-server-5.6 mysql-server/root_password password senha_aqui" | sudo debconf-set-selections echo "mysql-server-5.6 mysql-server/root_password_again password…
-
3
votes2
answers306
viewsA: IF condition between Mysql PHP tables
The way you’re relating to INNER JOIN will always return the values where forma_pagamento_id is equal to forma_pagamento_selecionado_id, then the if there will be useless besides being declared…
-
0
votes3
answers433
viewsA: My json returns invalid character in PHP
As an alternative, and decreasing some lines of code, use the fetchAll to get a array containing the elements of the returned lines in the sql and the function array_map to apply the utf8_encode in…
-
0
votes3
answers69
viewsA: Loop of DIV’s in PHP
If the first element has no problem with margin-top equal to 0 (zero), start the incrementer $i with him: <?php for($i=0; $i<=5; $i++): ?> <div class="papel" id="papel"…
-
2
votes0
answers69
viewsQ: API Analytics returns incorrect date with correct values
Using the Analytics SDK to perform queries, I enter the values for the dimensions, metrics, start-date and end-date. I get the result of the query with the correct data as I checked in the panel…
-
0
votes1
answer69
viewsA: PHP Chart - how to call the BD and adapt the variables to the chart?
Try changing your code to the following structure: while($row=$graph->fetch_assoc() and $i<=$graph->num_rows){ $data=date('M',strtotime($row['data'])); $data[$i]['label'] = $data;…
phpanswered Marcelo de Andrade 7,261 -
1
votes1
answer207
viewsA: Read json data inserted in mysql
There’s no problem in not having [], means only that its object JSON has only one collection of objects and there is no array in it. You can access the value as follows: $jsonString =…
-
3
votes1
answer107
viewsQ: Is there a distinction between software that has a database or not?
A doubt that came to me while I was studying and that I still haven’t found anything about it. We know what a software, here a brief definition: A program (software) is a sequence of instructions…
-
7
votes1
answer301
viewsQ: Workflow to revert dev branch changes to master
The branch dev is automatically merged to the master; this, for his time, there’s a deploy automatic application. The branch dev has some changes ahead of the branch master and will be disposed of.…
gitasked Marcelo de Andrade 7,261