Posts by Bacco • 93,720 points
1,184 posts
-
8
votes1
answer1009
viewsA: What is the difference between `filter_var`and `filter_input`?
Filter_input and filter_var functions: The basic difference is that the filter_input plays the role of filter_var, but already picking from an input variable (such as GET or POST). This code right…
-
20
votes3
answers4785
viewsA: PHP and Mysql, how are thousands of connections processed at the same time?
P: "If there are 1000 connected clients on the site requesting Mysql, then there are 1000 Mysql connections?" R: Only if the 1000 start at exactly the same time a navigation on the pages that use…
-
8
votes1
answer1759
viewsA: Center div parent when children have dynamic width
Using flexbox: HTML: <div class = "container"> <div class = "box a">1</div> <div class = "box b">2</div> <div class = "box c">3</div> <div class = "box…
-
5
votes2
answers8336
viewsA: How to center the <th> header of an HTML table with css?
As already mentioned by @Andorinha, first of all we will exchange the ids for class: ... <th class="cabecalho" >Ação</th> ... <th class="cabecalho" >Comédia</th> ... etc…
-
6
votes1
answer11317
viewsA: Float rounded in C
float n1 = 4; float n2 = 9; float total = n2 / n1 ; float truncado = floor( total * 10.0f ) / 10.0f; printf("Media: %.1f ", truncado ); printf("Media: %.2f ", truncado ); printf("Media: %.5f ",…
-
2
votes1
answer99
viewsA: Decreasing connections to the database
To catch the first item when arriving at the last: // Pegamos o próximo $proximo = $pdo->query("SELECT * FROM postagens WHERE id > ".$pid." AND id_user = ".$cid." ORDER BY id LIMIT…
-
3
votes2
answers1507
viewsA: How to display multiple error messages simultaneously in form?
You can use separate variables for each type of error, and index them in the respective fields. So that messages can appear simultaneously, I refactored your code, allowing the treatment of each…
-
4
votes1
answer577
viewsA: Opening page via AJAX with Lightbox
For this, you need the HTML5 History API: history.pushState( estado, titulo, url ); As you just posted the main code, I can not put details at the moment, but for the desired purpose, the essential…
-
10
votes2
answers23592
viewsA: Using a class function within another PHP class
An option would be to instantiate a new object within the class, for example: class MinhaClasseDois { public function minhaFuncaoDaClasseDois() { $objeto = new MinhaClasseUm(); $banana =…
-
10
votes2
answers22549
viewsA: How to include Bootstrap Glyphicon inside the "<input></input>" tag?
To get buttons with icon, keeping the input tag: A very simple solution is to use the label and hide the submit original: <label for="salvar" class="btn"><i class="glyphicon…
-
5
votes1
answer109
viewsA: Next value in a random order of numbers
If Ids are in ascending order (1, 4, 37, 1278, 12888): SELECT id FROM artigos WHERE id > (PONHA O ID ATUAL AQUI) ORDER BY id LIMIT 1 and to get the previous: SELECT id FROM artigos WHERE id <…
-
4
votes3
answers901
viewsA: Infinite loop with $_SESSION and redirect
If the problem is a include on all pages, just add one or more exceptions. Example: if( $_SERVER["PHP_SELF"] != '/index.php' && !isset($_SESSION['email'], $_SESSION['senha'],…
-
3
votes1
answer858
viewsA: Ordering a Listview alphabetically in Vb 6
Seven this when building the ListView: minhaListView.Sorting = SortOrder.Ascending
-
5
votes4
answers713
viewsA: Search from between dates
Follows SQL that takes into account the birthday date: SELECT * FROM candidato WHERE dt_nascimento BETWEEN DATE_SUB(NOW(), INTERVAL 20 YEAR) AND DATE_SUB(NOW(), INTERVAL 30 YEAR) (line breaks added…
-
1
votes2
answers923
viewsA: utf-8 encoding in XML file to generate RSS
An initial idea would be to use htmlentities to have no trouble with encoding: while($row = mysql_fetch_array($result)) { $title = htmlentities( $row['titulo'], ENT_COMPAT, 'utf-8' ); If not enough,…
-
5
votes4
answers2291
viewsA: With Delphi, how can I disable the ESC key for all apps?
Alternative answer, using the record: just create a text file "qualquercoisa.reg" with this data: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard…
-
4
votes1
answer67
viewsA: File creation for database data logging
$contador = 0; while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ if( $contador++ % 1000 == 0 ) { // assim teremos um ExcelWriter no 1o item de cada 1000. $excel = new…
-
6
votes3
answers537
viewsA: Run script every 1000 queried records
Updated to demonstrate that the solution also meets the question update Just insert this into the while (keeping the $contador = 0 original on the outside): if( $contador++ % 1000 == 0 ){ echo…
-
5
votes3
answers9315
viewsA: Sum results values in mysql
I added having to filter after group, and separation of rates and discounts: SELECT SUM( IF( valor > 0, valor, 0 ) ) AS taxas, SUM( IF( valor < 0, -valor, 0 ) ) AS descontos, SUM(valor) AS…
-
7
votes2
answers1679
views -
4
votes2
answers1834
viewsA: How to separate text icon in a <div>
You can simplify the code a little by using the image as a div background, and adding a padding (internal spacing) larger side where the image will be. In the example below, note that the class has…
-
16
votes5
answers7269
views -
25
votes4
answers9578
viewsA: What is the modern alternative to framesets?
The iframe: You can use the "cousin" of <frame>, the <iframe>, which, in addition to being supported by HTML5, has gained some new attributes. With the iframe, normal HTML can be used on…
-
2
votes1
answer2099
viewsA: How to remove the "extract here" submenu option from a sfx (exe)?
Follow the menu in this sequence: Options > Preferences Integration tab > Shell Items from the contents menu There you define all the options you want in the menu. There may be some variation…
-
6
votes3
answers33562
viewsA: Update records from one table using values from another table
You need a UPDATE JOIN in this case: UPDATE produtos [INNER JOIN | LEFT JOIN] movimentacao ON produtos.codigo = movimentacao.Codigo SET produtos.fornecedor = movimentacao.Fornecedor WHERE condicao…
-
6
votes2
answers1559
viewsA: Image distortion with CSS?
A CSS2 solution (for a CSS3, see @Sergio link): Create an image with the shadow: CSS .sombra { width:530px; padding: 0 10px 20px 10px; background: #fff url('/sombra.png') center bottom no-repeat; }…
-
5
votes1
answer363
viewsA: Detect Caps Lock C#
Using Console.Capslock Console.WriteLine( "Caps Lock " + ( Console.CapsLock ? "Ligado" : "Desligado" ) ); To check the status after returning to the application, it would be the case to do a…
-
7
votes1
answer3011
viewsA: How to validate date of birth between the year 1900 and Today?
I called your variables $dia, $mes and $ano for easy reading. If you want to know if the date is valid, just use the checkdate: checkdate( $mes, $dia, $ano ) // Atenção à ordem dos parâmetros. To…
-
4
votes1
answer2194
viewsA: How to show the number of views of each page of the site with PHP?
Imagine the following: You have a relational database, with tables. Tables we relate to rows and columns. Usually more rows than columns, in most cases. Generally what varies in tables is the number…
-
1
votes2
answers174
viewsA: Receiving code 200 when it should be 404
Try reversing the verification sequence: protected void Application_Error(object sender, EventArgs e) { Exception Ex = Server.GetLastError(); if (Ex != null) { HttpException httpEx = Ex as…
-
3
votes1
answer468
viewsA: Pick key value set with hyphen
The elements of SimpleXMLElement comply with the variable name conventions of the PHP, and the - is not an allowed character. In this case, use { and } to encapsulate the name of these elements:…
-
10
votes2
answers2031
viewsA: How to take the position of an individual user in a rank, if in the database I only have your score?
The query: SELECT COUNT(*)+1 FROM rank WHERE pontuacao>(SELECT pontuacao FROM rank WHERE email = '$email' ) Using in the PHP: $email = (EMAIL DO USUARIO LOGADO); // Sanitize para evitar SQL…
-
5
votes2
answers186
viewsA: How do I add real-time analytics of views to my questions and answers in the OS?
How about using the Stack Exchange Own API ? Look at a little fragment of what you can do: Api de respostas: /answers Obtem todas as respostas do site /answers/{ids} Obtem respostas identificadas…
google-analyticsanswered Bacco 93,720 -
8
votes1
answer17853
views -
15
votes2
answers17077
viewsA: Convert milliseconds to hh:mm java format
1) Rapid response: String.format( "%03d:%02d", ms / 3600000, ( ms / 60000 ) % 60 ); 2) Mathematical "traditional" solution: Calculating the fields: Supposing ms is the millisecond variable: segundos…
-
29
votes2
answers1282
viewsA: What does <<< EOH in PHP do?
Definition of strings in PHP Like most languages, PHP allows you to define strings, i.e., strings of characters literally, starting with quotation marks (") , or per apex (') - which some call…
-
50
votes3
answers8575
viewsA: Why is it recommended to use the "in" unit instead of "px" for fonts?
In fact, it is not "recommended to use the "em" unit instead of "px" for fonts". The key is to understand how each measure works, to know in which cases it applies. There are cases where the em is…
-
3
votes2
answers159
viewsA: Regex in Mysql to fetch certain X tempo results
For complete dates: -- Se seu campo for DATE: SELECT * FROM tabela WHERE DATE(minhadata) = '2014-05-21'; -- Se seu campo for VARCHAR: SELECT * FROM tabela WHERE LEFT(minhadata,10) = '2014/05/21'; To…
-
3
votes3
answers5051
viewsA: Include link in a container
The exchange of DIV by a A allows the use of href traditional, and works even without JS: CSS: .container { display:block; position: relative; z-index: 2; text-decoration:none; ... outras…
-
2
votes4
answers138
viewsA: How to get the last more "+" that appears on the console from this code?
Simplified solution: ... } int count=ndivisoes; // Mantive a linha acima, que não é usada, apenas para você ver de onde eu comecei o código. String soma=""; for(int j=ndivisoes;j>=0;j--){…
-
5
votes1
answer154
viewsA: How to increase the distance to appear icon that expands menu
This value is defined by one or more lines similar to this in css: @media ... max-width: 1200px The min-width and max-width determine what page size will receive that CSS, adjusting as your need you…
-
3
votes1
answer2633
viewsA: It is possible to deny access to the directory and allow access to the file with . htaccess? how?
To not list your directories, just use this directive: Options -Indexes In the .htaccess or in the directory configuration: <Directory /www/pasta> Options -Indexes </Directory> Remember…
-
2
votes2
answers384
viewsA: How to resolve problems in HTML file calling?
One of the steps is to add these RewriteCond to do the rewrite only when there is no file or folder with the requested name: RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond…
-
3
votes3
answers19465
viewsA: Convert string to MYSQL integer
Just force a numeric operation on the string: SELECT mov.* , prod.produto, prod.unidade, prod.icms, prod.ipi, cast(prod.codigo as unsigned integer) FROM movimentacao AS mov, produtos AS prod WHERE…
-
6
votes1
answer1050
viewsA: How to download images sequentially from a website using Wget?
Solution Before using this loop, type cmd /v in the console to enable parameter expansion: set i=1000 && for /l %a in (1,1,200) do ( set /a "i=!i!+1" && wget…
-
5
votes1
answer111
viewsA: Cancel changes to Angularjs
You are just creating a new reference to the object, so any change in the original reflects on the reference. The exit is copy the original object, and recover the backup of this copy. $pageContent…
-
13
votes5
answers23456
viewsA: Add character in the middle of a string
Splitting the string in half var string = "aacc"; var metade = Math.floor(string.length / 2); var resultado = string.substr(0,metade)+"bb"+string.substr(metade); // o código abaixo é só para teste:…
-
4
votes1
answer786
viewsA: Query show image
For example, let’s assume it’s stored in Nome the team/team: echo'<img src="/imagens/'.$exibe["Nome"].'.jpg"> Then you save the image as /imagens/Real Madrid.jpg. The spelling has to be…
-
87
votes2
answers38176
viewsA: How do hexadecimal numbers work?
Numbers are simply numbers It may sound strange, but there’s not much to learn in hexadecimal that’s different from the math you already know. The mathematics of binaries, decimals, hexadecimals…
-
10
votes4
answers33008
viewsA: How to create a raise image effect by hovering the mouse over
A simple solution with css: CSS: #teste{position:relative} #teste:hover{top:-2px;box-shadow:0 2px 2px #666} HTML: <img src="/imagem.png" id="teste"> If you want to simplify, for older…