Posts by Bacco • 93,720 points
1,184 posts
-
5
votes2
answers156
viewsA: Perform 3 simultaneous searches in the same table
An output with mysqli is to use multi-query. Follow an example from PHP documentation: <?php $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if…
-
2
votes2
answers1296
viewsA: How to get operating system time in nanoseconds or milliseconds using Qt Creator?
Using the Qt Follows an example adapted from the Qt documentation: QTime t; t.start(); // Aqui inicializamos a contagem // seu código treinaRNAEpocas(10000); //resultado da medida qDebug( "Tempo…
-
2
votes1
answer65
viewsA: How to send multiple different data by email?
First, you should change the form a little to make things easier: <table id="add_estabelecimento_table" border="0" style="margin: 0px 0px 20px 0px;" cellspacing="0" cellpadding="0"> <tr>…
-
3
votes2
answers47
viewsA: Always equal table check
An alternative, just to illustrate the use of num_rows: <?PHP $status = mysqli_query($connecta, "SELECT `online` FROM `char` WHERE `name`='[ADM] koda' AND `online` = 1"); $resultado =…
-
17
votes3
answers2688
viewsA: How to identify and print perfect squares with Javascript?
Note that your example is incorrect as 1 is perfect square as well. Follows a possibility, without much optimization: function QuadradoPerfeito( n ) { var i; var out = ''; var root; for ( i = 1; i…
javascriptanswered Bacco 93,720 -
4
votes3
answers913
viewsA: Multiple of 10 closest to a sum
A version similar to the question, but using module: (I still prefer the purely mathematical solution) def multiplo(x): somamulti= somaImpares(x) + somaPares(x) if somamulti % 10 == 0: return…
-
3
votes1
answer680
viewsA: If/Else in Ruby
See the difference between using Else and elsif in both versions: puts'Por favor, digite sua idade: ' idade = gets.chomp idade = idade.to_i if idade >= 18 and idade < 65 print'Legal, você é…
-
2
votes1
answer435
viewsA: How do I put a menu below the logo?
It’s because there’s no menu in your code. A HREF is used to link a page in the sense that it is accessed by clicking on something, for example: <a href="http://answall.com'>Clique aqui para…
-
3
votes6
answers96354
viewsA: How to make an "Alert" in PHP?
A possible solution, which merges the proposals of the other answers, is to assemble a minimum HTML, but using a META to refresh it take a few seconds without disturbing ALERT: <?php…
-
6
votes1
answer657
viewsA: Generating a hexadecimal string
Wouldn’t it be the case to use one UUID.randomUUID() simply? Example: import java.util.UUID; class GerarUUID { public static void main(String[] aArgs) { UUID id = UUID.randomUUID();…
-
4
votes3
answers751
viewsA: Send email with dynamic content in PHP
You can easily replace keywords from your template using something like this: <?php //Aqui você define as variáveis na lógica do seu script $nome = "Joaquim Augusto"; $quantidade = "100"; // Abre…
-
4
votes1
answer43
viewsA: Function calculation of month
var CountMes = 0; function DataTabela(mesInicial, Diferenca) { var Meses = []; Meses.push(mesInicial); while (CountMes < 5 && Diferenca > CountMes) { CountMes++; mesInicial++; //////…
javascriptanswered Bacco 93,720 -
3
votes1
answer554
viewsA: Accent and port problem on localhost
These are two questions of a very different nature, but posted as one, it would be interesting if the next ones were asked separately. Anyway, there it goes: Defining Apache charset headers: In the…
-
5
votes2
answers122
views -
6
votes2
answers786
viewsA: Dynamically assemble URL parameters
With the same principle as @Jorgeb’s answer, I adapted it to generate the filters specified in the question edit. Taking advantage, I added an option to remove an existing filter: <?php…
-
3
votes1
answer168
viewsA: Change soon according to the page
Doing this in JS on a PHP site is kind of a "gambiarra". Ideally, you want to solve this in PHP itself. For example, creating a variable before include: php paginaresgate. <?php $logo =…
-
6
votes5
answers6566
views -
3
votes2
answers676
viewsA: Catch last delimiter with explode
Complementing what has already been answered previously, there are some alternatives to pathinfo, only to show other means of working with strings, given the high performance in the case of such…
-
8
votes1
answer830
viewsA: ERROR: This application is failed to start because it could not find or load the Qt Platform plugin "windows"
From Qt5 you must have the following structure: +-+ pasta do aplicativo) |-- Aplicativo.exe |-- Qt5Core.dll |-- Qt5Widgets.dll |-- outras dlls dos módulos usados +-+ platforms |-- qwindows.dll The…
-
1
votes3
answers6793
viewsA: How to execute multiple cmd commands in VB.net
For this type of interaction you need a Process: dim proc as ProcessStartInfo("cmd.exe") dim pr as Process pr=Process.Start(proc) pr.StandardInput.WriteLine("comando1")…
-
5
votes1
answer330
viewsA: Make Animate with scrollTop
Probably something in this line you need: $(/* elemento desejado, ou simplesmente window */).bind('scroll', function() { if ($(window).scrollTop() >= 1110) { $("#parte3").css("display", "block");…
-
8
votes1
answer199
viewsA: Dynamically create variable
You must use arrays inside arrays for this, and not eval. Syntax: for(var y = 1; y <= 2; y++ ) { max_arr[y] = Math.max.apply( null, arr_valeur[y] ); } Example: var arr_valeur = []; var plus_grand…
javascriptanswered Bacco 93,720 -
52
votes4
answers3512
viewsA: What do reticence in the parameters of a method mean?
What you have in the mentioned example is the setting that parameter params will receive the arguments in a string array, from Java 5.0+ (this definition is known as "varargs"). In other words, you…
-
8
votes1
answer9778
viewsA: Tag <p> rendering Line Break (no <br />)
The output is correct from the following point of view: browser is putting the break only where there is space between words. To circumvent this behavior, you need to specify word-wrap: break-word…
-
4
votes3
answers1750
viewsA: Smooth element animation swing via CSS Transform
Forgetting a little bit about the code part, let’s think about the following: When a rounded object resting on the ground rotates, it also moves to the side corresponding to the turn. Moreover, the…
-
10
votes2
answers2925
viewsA: Consultation in table with self-relationship
If you want all categories, it seems to me the case to use LEFT JOIN: SELECT c.*, p.categoria AS catpai FROM categoria AS c LEFT JOIN categoria AS p ON c.pai = p.idcategoria; Notice that I used…
-
4
votes1
answer3373
viewsA: Configure Sheet Margins in FPDF
First, it is important to set the page size correctly when creating it: $pdf = new FPDF('P','mm',array(210,297)); // P = Portrait, em milimetros, e A4 (210x297) The margins in the FPDF depend on the…
-
5
votes1
answer1914
viewsA: Procedure oracle to copy data between tables
One solution is to create the table from scratch with the data from the previous one: CREATE TABLE TAB_FORNECEDOR2 AS SELECT * FROM TAB_FORNECEDOR; Recalling that to do so you must remove…
-
5
votes3
answers179
viewsA: CSS, center split line between left and right
A simple example of how to put a line in the middle, using border: div { position:relative; /* Uma espécie de "reset" para os divs se comportarem bem */ box-sizing:border-box; /* Ajuste para que o…
-
2
votes1
answer333
viewsA: Performance in Mysql Database Queries
Use two SELECTS separate makes sense only if you are taking data from different tables or very varied criteria to each record. Every time you make one query by PHP, a new request is made to the DB…
-
6
votes1
answer55
viewsA: Transcription javascript calculations for PHP
Follows something like: <?php $html = ''; $limitItem = 49; for ($i = 0; $i < $limitItem; ++$i ) { $w = rand( 1, 4 ); // Confira se é de 1 a 4 mesmo que deseja $width = $w * 150; $index = $i +…
-
12
votes4
answers38774
viewsA: Sequential numbering of query results
Solution for Mysql: Whereas the numbering may be volatile, and Mysql does not have a line counter by default, it follows a query that fills the count using @variáveis: SET @contador := 0; SELECT…
-
4
votes6
answers2305
viewsA: Transform results combination function into a dynamic function
Follows a combination function that allows you to use an array as data input: function combinations( inpSet, qty ) { var inpLen = inpSet.length; var combi = []; var result = []; var recurse =…
-
3
votes2
answers1955
viewsA: Why is the initial state of a required <input> invalid?
If you have a field at the same time required and an empty field, it is in fact an invalid field - after all, a required field, to be valid needs to have data :) What you can do in this case, to…
-
3
votes1
answer561
viewsA: How do I call a . dll and declare functions in C++. Net
From the comments, I believe the problem is in Handle’s statement: HMODULE LoadDLL(void) { HMODULE handle; // Carrega a dll ... handle = LoadLibrary(L"c:\windows\system\minhadll.dll"); // Verifica…
-
4
votes1
answer2754
viewsA: Javascript Alert is not working
A problem with your solution is that you want at the same time to use an Alert and redirect the user to another page. Here is a suggestion to solve the problems: save the messages and send them back…
-
4
votes1
answer113
viewsA: How to return the 'Parent ID (Main)' in this Mysql query?
A possible solution is a function, but if it is something that will be widely used, it compensates or add a field in the table to the category "master", and process the tree only in modifications…
-
2
votes4
answers1289
viewsA: Javascript URL redirect code
Follows a function that already tests whether the parameter exists in the original URL, and if it does not exist, adds. This function is prepared for cases where other specified values already…
javascriptanswered Bacco 93,720 -
5
votes1
answer4358
viewsA: Problem with uploading files to the server
Note: This answer was posted before the author of the question changed the code. To later question, on the basis of screenshot, may be the cause of the problem. Anyway, I’ll leave it here because it…
-
1
votes2
answers89
viewsA: Css in different resolutions and browsers
The biggest problem with your code is that you haven’t reset the main properties of things, so the result is unpredictable. See the important points added here: reset to margin, padding, and…
-
4
votes1
answer105
viewsA: Values are not in the right column in the table
a patch in your code is this: <tr> <td><?= $row['id']?></td> <td> <?php foreach($results as $values) { if($values['id'] == $row['id_empresa']) { echo…
-
4
votes4
answers714
viewsA: Trying to condense conditional with three possibilities
Version without if: I would normally do this in PHP 5.4+ (which allows direct access to arrays): $ni = 6; echo array('nenhum', 'um ítem', "$ni ítens")[min($ni,2)]; 5.5 (I do not remember if 5.4…
-
7
votes6
answers14224
viewsA: Distribute list of <li> in two columns
Here is a CSS3 solution that takes into account several factors: Variable width: you can change the size of the UL, which the cells will follow; Security when setting the 50% not to "burst" the…
-
2
votes2
answers502
viewsA: make invisible the <li> when inside has no <ul>
Since you commented that the solution is palliative, could hide all and show the ones that matter (XGH method): $('body > ul > li').hide(); $('body > ul > li ul').parent().show(); But I…
-
4
votes1
answer5224
viewsA: Default Timestamp Mysql
When creating the field, set it like this: dataHora TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP; If you are going to modify the structure of an existing table, use this query before of the…
-
4
votes1
answer488
views -
5
votes3
answers144
viewsA: How to play items with a specific value for the beginning of an array?
We already have good answers, but follows a version that sorts by several columns, using the .sort traditional, if someone needs in the future: var perguntas = []; perguntas[0] = { id:1, ordem: 3,…
-
3
votes3
answers242
viewsA: Show in alphabetical order table
The right thing would be for you to sort before, on the list that picks up the Ids. But if you use XGH technique to solve the problem, you can store it in a array the data, and order to show:…
-
5
votes2
answers578
viewsA: Decrement PHP variable by clicking a form button
The problem is that you are zeroing out all PHP calls. Here’s a very simplified example of how to persist data between one click and another: <?php if( isset( $_POST['mes'] ) ) { $mes = 0 +…
-
3
votes1
answer66
viewsA: Mysql query with undesirable items - PHP
By default, the result of mysql-fetch-array comes with numeric indexes and also with indexes corresponding to the name of the bank. If you want only one of the two things, you need to use the second…