Questions tagged as 'php'

4
answers

How to continue incrementing the value of a variable even after a page is reloaded?

I wanted to put in to add +1 to variable $a every time the page loads. I've already used the code: $a = ++$a; echo $a and also the: $a = $a++; echo $a But it only adds once, and when I refresh the page, it does...
asked by 09.07.2017 / 04:34
3
answers

I need an explanation of what a code I do not understand does

I need to make a change to a code and found this: <?=(((++$i % 2) == 1) ? 'class="colored"' : '')?> What does this code do?     
asked by 16.11.2015 / 14:21
4
answers

Different ways to count record numbers in MySQL

There's a difference in performance if you do: //seleciona todos os itens da tabela $cmd = "SELECT * FROM produtos"; $produtos = mysql_query($cmd); //conta o total de itens $total = mysql_num_rows($produtos); instead of executing a query:...
asked by 23.01.2015 / 14:42
1
answer

Is it possible to know at what point the script reaches peak memory?

Is it possible to know at what point the script reaches peak memory? I have a PHP script that in the end shows this result:    Use: 380.515625Kb       Peak: 393.5859375Kb       Real: 512Kb Example: <?php ... echo PHP_EOL,...
asked by 02.06.2015 / 06:31
2
answers

Search system listing error with pagination

When I query, I get the following result [image1] When clicking to go to page 2, I get the following result [image2] That is, on page "1" everything works with the total results displayed (10) and total links (2), but when going to page "2...
asked by 04.09.2015 / 00:33
1
answer

PHP - Make 3 INSERT on different tables with relationship between them

I would like your endorsement. I need to do 3 INSERT at once. But I also need to get the last ID of each table to do the relationship of the tables. Is this correct, to do this? if($_GET['operacao'] == 'addPrimeiroCadastro'){...
asked by 18.12.2015 / 02:59
1
answer

Mysqli bind with an array of values

I have a code in PDO and I need to convert this code to mysqli, at this moment I have something like that: $sql = "SELECT * from tabela where nome = ? AND idade = ? AND outro = ?"; $stmt = $core->conn->prepare($sql); $bindArray = array...
asked by 04.12.2015 / 12:56
2
answers

Identify and get PUT and DELETE variables

I'm developing a solution for API , I can currently identify the method by: $_SERVER['REQUEST_METHOD'] How can I get the variables PUT and DELETE ? As in GET and POST I use: $_POST; $_GET; When executing a r...
asked by 17.12.2016 / 21:03
4
answers

How to format this array?

I have the following array: $dados = array( '0' => array( 'id_assinante' => $id, 'nome' => 'Aluguel' ), '1' => array( 'id_assinante' => $id, 'nome' => 'Água' ), '2'...
asked by 21.12.2016 / 12:14
3
answers

Using the .env file in the PHP project?

I noticed that Laravel uses the .env file for some settings and in code it a env() function, I ask: Is there any way to use the .env file in my project php without using some framework ? If yes, ho...
asked by 11.10.2017 / 17:03