Posts by Bacco • 93,720 points
1,184 posts
-
2
votes2
answers251
viewsA: jQuery adding several lines in html
Just to complement the @bfavaretto response, if in any situation you have to put a result in a predetermined place, you can use the .text to change only the contents of an element: var resultado =…
-
11
votes4
answers2486
viewsA: How to make this arrow in CSS
No image, no HTML change: Using borders you can improvise with CSS only, without needing any image: .flecha::after { display:block; position:absolute; content:''; left:-26px; top:-3px; width: 20px;…
-
7
votes2
answers300
viewsA: Return N elements from a list in jQuery
If you want a continuous list, it could be slice: Take an example: $('#tabela tr').slice( 2, 4 ).css( "background-color", "red" ); <script…
-
5
votes1
answer115
viewsA: Variable reference in Javascript
If you want to change values independently, you need something like this: var linha = [1, 2, 3, 4, 5]; var matriz = []; for( var i = 0; i<5; i++ ) { matriz.push( linha.slice() ); } //testando…
-
2
votes1
answer903
viewsA: How to go through and compare two arrays in PHP
Try it like this: $result = array_diff ( array_unique( array_merge($array1, $array2) ), array_unique( array_intersect( $array1, $array2 ) ) ); print_r($result); See working on IDEONE.…
-
2
votes1
answer61
viewsA: How to list a query without knowing what will be returned?
To show the results, just this: <?php while ( $row = mysql_fetch_array($qry_result, MYSQL_NUM) ) { echo '<tr>'; foreach($row as $item) { echo '<td>'; echo htmlentities( $item ); echo…
-
2
votes2
answers975
viewsA: Make a conditional update on ON DUPLICATE KEY
As ON DUPLICATE KEY does not allow conditional situations **, perhaps the best solution is a stored Procedure: ** but see an outline for this limit in the @Thomas response, which transfers the…
-
2
votes1
answer552
viewsA: How to separate string that Soap generates?
You don’t need to separate anything, the return is probably in order and separate. The problem is just the way you are displaying the data on the screen. You can see that even your string between…
-
8
votes1
answer135
viewsA: Keep SVG line by always connecting two objects
Considering the line syntax: <line x1="20" y1="100" x2="200" y2="220" stroke="black" stroke-width="2"/> What you need to do is animate the desired property. In your case, you will have to make…
-
5
votes1
answer1575
viewsA: How to put the data of a while inside a variable?
There’s a lot of shape. Here one in text format, to use for example in the body of an email: $separador = ''; $codigos = ''; while( $TiV = $frm_interesse->fetch() ) { $codigos .= $separador.…
-
2
votes1
answer88
viewsA: How to change alphabetic and numerical pager?
To make the index, you can adjust this way: SELECT UPPER(LEFT($coluna,1)) AS inicial WHERE UPPER(LEFT($coluna,1)) >= 'A' AND UPPER(LEFT($coluna,1)) <= 'Z' FROM $db GROUP BY inicial ORDER BY…
-
2
votes1
answer632
viewsA: Numerical sequence
Probably solving in the database is the best way to what you asked. In the part you query: SELECT cliente FROM clientes ORDER BY totalcompras DESC LIMIT 20 If purchases are on another basis (which…
-
1
votes1
answer214
viewsA: Using Left Join on Datatable Server-Side
It shouldn’t really work, because you already have one WHERE in the middle of SELECT and you can’t have the one in the filter together. The question is confused, but it’s probably something along…
-
5
votes5
answers611
viewsA: How to count items correctly?
Since you have a comma at the end of the string, PHP will count the 1, as two items, the first being the 1, and the second void. The ideal would be to organize the DB not to have this type of…
-
1
votes2
answers1315
viewsA: Convert Empty string to integer to insert into database
You can use this syntax: int numero = StringUtils.isNotBlank(minhaString) ? Integer.parseInt(minhaString) : 0; Thus the parseInt is used only if the minhaString is not empty. Theoretically, as…
-
9
votes3
answers10114
viewsA: Which JSON structure to use for large data volume without loss of performance?
If the system is very well documented, nothing prevents you from removing everything that is not necessary and do just that: [ ["João", "Silva"], ["José", "Barbosa"], ["Maria", "Joana"] ] (line…
-
3
votes1
answer523
viewsA: Make $_SESSION work as session_register
Don’t do this. Just do it at the end of the code: $_SESSION['nome'] = $nome; And at first recover with $nome = $_SESSION['nome']; ...But if you really want to do it, one solution would be this:…
-
6
votes1
answer268
viewsA: case sensitive PHP
If the problem is in query: $requete = "SELECT * FROM contact WHERE LOWER( nom ) = LOWER( '$search' )"; or else: $search = mb_strtolower( $search ); $requete = "SELECT * FROM contact WHERE LOWER(…
-
6
votes2
answers199
viewsA: How to prevent user registration with Login initiated by number or symbol
I adapted your own logic: <?php $ascii = ord( strtoupper( $loginPost ) ); if( $ascii < 65 || $ascii > 90 ) { echo 'o Login precisa comecar com uma letra'; else echo 'Usuario Cadastrado'; }…
-
5
votes3
answers1789
viewsA: How to apply background-color to the p HTML element?
Your CSS is working perfectly well, just missed understand how it works <p>. By default, the width of a paragraph is 100%, even if the text contained in this does not take the whole width. To…
-
4
votes4
answers1666
viewsA: SQL Injection via url
Joining what I had already commented with Q&A pointed out by Marcio, follows a modification that solves the problem in the first two lines of code, saving an unnecessary application layer for…
-
8
votes1
answer5329
viewsA: Calling PHP variable inside a Javascript function
The solution would have to be a little more elaborate. On the home page: Put the PHP part that processes variables at the beginning of the script, and add something like this in the PHP part:…
-
2
votes1
answer72
viewsA: How to pay for browser data after registering in the database
A possible solution without major changes in the code is this: if($cadastra == '1') { // Montamos o caminho para o mesmo script: $url = 'http://'.$_SERVER["SERVER_NAME"].'/'.$_SERVER["PHP_SELF"]; //…
-
4
votes2
answers391
viewsA: Use URL rescrita as array in . htaccess
A possible output is to send all addresses to the same PHP: Options -Indexes RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1…
-
2
votes2
answers578
viewsA: Show table header only once
The problem is that when you use this code, you are mounting several tables: $cont = 0; while($row = mysql_fetch_object($query)) { if($cont %2 ==0) { $cor = "#EDEDED"; } else { $cor = "#FFFFFF"; }…
-
2
votes2
answers1563
viewsA: Refresh a page after Submit PHP
It follows an alternative adapted from a reply from Sozão: This code is an interesting alternative if you prefer that the control is on account of the window that opens the popup, and not within the…
-
5
votes2
answers1097
viewsA: How to persist/fill in form data via PHP?
Just for the desired value on value text fields, or option checked and selected us checkboxes and selects desired. Example for text field: $nome = $_GET['nome']; $form_nome = htmlentities( $nome );…
-
4
votes2
answers109
viewsA: Do not execute command line
Use the wsrlua.exe in place of srlua.exe and the console will not automatically open. The command line would look like this: glue.exe wsrlua.exe meuscript.lua meuexecutavel.exe Note that basically…
-
8
votes2
answers781
viewsA: Group items by a field into different arrays
It’s probably easier to make the output stay in a sub-array: $saida = array(); foreach ($resultado as $res) { //se o indice id_serv ainda nao estiver na $saida, adicionamos uma array vazia: if(…
-
8
votes1
answer438
viewsA: Mark an image with a dot
If what you really want is what’s in the question, using PHP, a solution is to use the GD library for this, which usually comes pre-installed in PHP distributions. See an example that draws a small…
-
5
votes2
answers148
viewsA: String "letter" position
a = "x x x" pos = 0 while 1 do pos = a:find( "x", pos + 1 ) if not pos then break end print( pos ) -- poderia armazenar numa tabela end Exit: 1 4 7 See working on IDEONE.…
-
4
votes3
answers1232
viewsA: How to extract a word from a PHP URL
If you want the penultimate chunk of the URL: This solution works with all the examples given in the question: $pedacos = explode('.',$texto); echo $pedacos[count($pedacos)-2]; Entrances: $texto =…
-
6
votes1
answer473
viewsA: I can’t solve a goal using ":Hover". What to do?
Generic solution: I tried to do only the essentials of CSS, and "chained" the frame with information precisely for you to test the Hover. Just change the dimensions and positions to the desired…
-
5
votes1
answer1487
viewsA: How to search a term in more than one table field
Usually just search the result of all concatenated terms: SELECT * FROM tabela WHERE CONCAT_WS( ' ', campo1, campo2, campo3, campo4 ) LIKE '%termo%' If you are looking for a way to search multiple…
-
4
votes1
answer112
viewsA: Data grid with function 0 in the rest PHP or PHP+Ajax
As this is a basic issue, I tried to make a very didactic code: <?php // Primeiro, vamos pegar um array com doze ítens para teste: $itens = array( 'um', 'dois', 'tres', 'quatro', 'cinco', 'seis',…
-
29
votes3
answers553
viewsA: In Python, what are the consequences of using is instead of '=='
The consequences depend on the purpose of the code. is and == are not synonyms, and cannot simply be exchanged as if they were. What happens is that in many situations, the two return the same value…
-
18
votes1
answer462
viewsA: Operator NOT (!)
The ! is the not. It returns false to a true value, and true to a false value. In other words, it "reverses" the logical value of an expression. != is not Equal, that is, "not equal", the same as…
javascriptanswered Bacco 93,720 -
2
votes1
answer138
viewsA: How to compare the value within a <span></span> and trigger an action?
With jQuery you can test this way: if( parseInt( $('#Preco').text() ) > 199 ) With Pure JS, you can test like this: if( parseInt( document.getElementById('preco').innerHTML ) > 199 ) But be…
-
3
votes1
answer562
viewsA: How to adjust the format dd/mm/yyyy
If you only want to store in a variable, you can use sprintf in place of printf: #include <Windows.h> #include <stdio.h> #include <time.h> void main () { char minhaString[30];…
-
2
votes1
answer1400
viewsA: Search registry by date in mysql
Wouldn’t it be simpler this way? SELECT * FROM tbl_lua WHERE nascimento >= data ORDER BY data DESC LIMIT 1; Test in SQL Fiddle the version that returns moons and quarters. Regardless of the…
-
16
votes5
answers53548
viewsA: Mysql decimal value
One of the options is to use DECIMAL( tamanho, casas ), but I particularly recommend using INT and multiply the values by 100. But first of all, you have to convert the value to a number with points…
-
3
votes4
answers1964
viewsA: Set placeholder with PHP variable
It only makes sense to use this if the variable is different from the field, because the placeholder only appears with empty field. And the way you’re doing, the placeholder will only be used empty…
-
5
votes2
answers137
viewsA: Faded transition between sprites
A simple example with button: .opa, .opa span { position:relative;display:block; width:60px;height:60px; margin:0;padding:0; border:none; } .opa { background:…
-
3
votes3
answers211
viewsA: How to go through the tuples for an ID and check their values?
If ID is numeric SELECT * FROM tabela_parcelas WHERE ID = 2 AND Situacao="Pago" if it’s string SELECT * FROM tabela_parcelas WHERE ID = "000002" AND Situacao="Pago" Edit: After your comment and…
-
9
votes1
answer402
viewsA: Percentage of Equality of Texts?
The Levenshtein Distance is one of the best known algorithms for this: Java: public class Levenshtein { public static int distance(String a, String b) { a = a.toLowerCase(); b = b.toLowerCase(); //…
-
3
votes2
answers102
viewsA: Is it possible to loop with a variable jump?
You can toggle the step when using the variable: for j in range(1, 20, 3): print(j if j & 1 else j + 1) Exit: 1 5 7 11 13 17 19 See working on IDEONE. If you want to adjust the moment the steps…
python-3.xanswered Bacco 93,720 -
14
votes3
answers44043
viewsA: How to put icon inside input using Font Awesome?
Serves with a little CSS "in hand"? Using Bootstrap: <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <link rel="stylesheet"…
-
3
votes1
answer409
viewsA: Copy (clone) an SVG element
First, insert the clone into the DOM, then modify the attributes (and make sure you’re calling the function clone() correctly in your code): function clone(){ var newrect =…
-
10
votes5
answers16703
viewsA: Fill left zeros in Javascript
Just use this operation on string: ("000000"+str).slice(-6,-1)+'-'+("0"+str).slice(-1) If you want to increment, you can filter before to remove the non-numeric: str="000000"+str.replace(/\D/g,'');…
-
3
votes1
answer113
viewsA: Move square with mouse only on vector X or Y
If you can, post a current code with traditional drag in all directions, which shows how to apply this logic when you have a little time. For now, it follows the logic in code "agnostic": By…