Posts by Jeferson Assis • 2,719 points
97 posts
-
5
votes3
answers715
viewsQ: Calculation of incorrect multiplication
For some reason when performing the multiple calculation by a floating value PHP always returns me the wrong value. Example: echo ((33 * 0.8) - 26.4); result: 3.5527136788005E-15 But the expected…
phpasked Jeferson Assis 2,719 -
1
votes1
answer32
viewsA: How to access, in PHP, values passed as parameter using jQuery.post()
Using the tag $_POST $filmes = $_POST['_filmes']; parse_str($_POST['cores'], $cores); To get each value of the sent arrays, just use the foreach foreach($filmes as $filme) { print_r($filme) } I…
-
1
votes2
answers223
viewsA: Receiving JSON Data - PHP
You can take the array key from the foreach: foreach($ActiveOrder as $key => $f) { echo $key; } The first error that appears is that there is no property return and the second because the…
-
2
votes2
answers1639
viewsA: Split values in Brazilian currency (R$) in php?
Need to treat the input value 6.999,99 for 6999.99 $valor = str_replace(',', '.', str_replace('.', '', '6.999,99'));
-
1
votes1
answer316
viewsA: How to apply two filters in a search field?
If you are using version 3.x of Cakephp you can do so: $user_email = $this->request->data('user_email'); $this->User->find('all', [ 'conditions' => [ 'OR' => [ 'User.name LIKE'…
cakephpanswered Jeferson Assis 2,719 -
1
votes2
answers127
viewsA: Make checkbox selected as database data!
You can check whether the checkbox array exists within the data coming from the database with the in_array $checked = (in_array(['origem'=>$yvalue, 'destino'=>$xvalue], $transicao) ?…
cakephpanswered Jeferson Assis 2,719 -
2
votes4
answers5730
viewsA: Share Link with Image on Facebook
Using targets og: <meta property="og:url" content="http://www.nytimes.com/2015/02/19/arts/international/when-great-minds-dont-think-alike.html" /> <meta property="og:type" content="article"…
-
1
votes2
answers71
viewsA: Problems with number_format(PHP) by two points in the numeral
If data input cannot be changed, use this solution: // Elimina a pontuação $value = str_replace('.', '', '100.235.32'); // Adiciona a pontuação correta $value = substr_replace($value, '.',…
phpanswered Jeferson Assis 2,719 -
1
votes1
answer407
viewsA: How to call an ACTION from a specific CONTROLLER via a Button?
The page URL has to be on FORM and not in the BUTTON echo $this->Form->create($row, [ 'url' => [ 'controller' => 'Groups', 'action' => 'index' ] ]); echo…
cakephpanswered Jeferson Assis 2,719 -
2
votes2
answers244
viewsA: How to sort array decreasingly?
Uses the array_count_values() along with the arsort(). $array = array('apple', 'orange', 'pear', 'banana', 'apple', 'pear', 'kiwi', 'kiwi', 'kiwi'); $output = array_count_values($array);…
-
1
votes1
answer114
viewsA: Updating of several Models and a single Cakephp 3.x form
You don’t have to create different objects when you have a relationship. http://book.cakephp.org/3.0/en/orm/saving-data.html#saving-Associations Creates the relationship in models //Model Campanhas…
-
0
votes2
answers74
viewsA: Invoices not paid more than 10 days
You can use the DATEDIFF() to check how many days passed from a certain date making INNER JOIN with the clients table. SELECT clientes.nome, faturas.data, faturas.valor FROM faturas INNER JOIN…
-
2
votes2
answers220
viewsA: Sending Push Notification messages to more than 1000 users at once
You can use the array_chunk to split into pieces of 1000 and then send. if ($android_tokens != array()) { $gcm = new GCM(); $data = array("title" => $title,"description" => $msg,"link" =>…
-
2
votes2
answers40
viewsA: Criteria for dynamic inputs
You can check in your looping the current time. //Captura a data selecionada $dataSelecionada = '2016-06-30'; for ($i=0; $i <= $total_horas; $i++) { $hora = ($i < 10) ? '0'.$i : $i; $hora…
-
0
votes1
answer255
viewsA: Query sql for cakephp
You can use this query using the ConnectionManager use Cake\Datasource\ConnectionManager; $connection = ConnectionManager::get('default'); $results = $connection->execute( 'SELECT * FROM…
-
0
votes1
answer32
viewsQ: Return tables with hasMany - Cakephp
In a relationship belongsToMany, when I turn the result into json ends up returning the field _joinData. Would there be some way not to bring him to the appointment or not to display on json using…
cakephpasked Jeferson Assis 2,719 -
0
votes1
answer693
viewsA: Ubuntu Linux server schedule delayed
I was able to solve my problem with the help of @Bacco by installing NTP on the server. 1º Install the NTL sudo apt-get update sudo apt-get dist-upgrade sudo apt-get install ntp ntpdate 2º Change…
-
1
votes1
answer693
viewsQ: Ubuntu Linux server schedule delayed
I have a Linux server running Ubuntu 14.4, configured with the timezone America/Sao_Paulo. But the time he is picking up this 2 min late, it seems little thing, but as the system that runs on it…
-
3
votes1
answer311
viewsA: Array by Swift parameter
To pass a array, just you put the type of it, optional add case ? func startGame(teste: [Int]?) -> String { let randomIndex = Int(arc4random_uniform(UInt32(wordHard.count))) let word =…
swiftanswered Jeferson Assis 2,719 -
1
votes2
answers830
viewsA: Mask in html field does not work
Just assign the masks on the return of your ajax mascara( document.getElementById('txtCel'), mtel); jQuery.ajax ({ url: "/admin2/controllers/contatos/Contatos.php?id="+id_contato+"&tipo="+tipo,…
-
3
votes3
answers210
viewsA: How to recover the first letter of a Swift array
You can use this extension extension String { subscript (i: Int) -> Character { return self[self.startIndex.advancedBy(i)] } subscript (i: Int) -> String { return String(self[i] as Character)…
-
1
votes2
answers168
viewsA: Retrieving the name of a boot on Swift
Just you take the sender.titleLabel.text, how he is a UIButton there is no property value How your Sender is AnyObject, you will need to cast him let value = sender.titleLabel.text as! String If…
swiftanswered Jeferson Assis 2,719 -
3
votes2
answers3826
viewsA: How to input weight mask using Javascript
Using the jQuery Mask plugin - http://igorescobar.github.io/jQuery-Mask-Plugin/ $(document).ready(function() { $('.weight').mask("#0.000", {reverse: true}); })…
javascriptanswered Jeferson Assis 2,719 -
6
votes1
answer6414
viewsA: How to put a link to download the app when the user enters my site by mobile
For iOS, you can use Smart App Banner Just add the metatag <meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL"> For Android has…
-
2
votes2
answers54
viewsA: Display user messages
You can use INNER JOIN to make this consultation. SELECT chat.id, IF(chat.sender = 6, utilizadores_reciever.username, utilizadores_sender.username) as username FROM chat INNER JOIN utilizadores as…
-
6
votes1
answer108
viewsA: Improve rating script (star rating)
I think something like that would be enough $nota = 3.6; for($i=1; $i<=5; $i++){ if($i <= $nota) { echo '<img src="estrela_ativa.png" />'; } else { echo '<img…
phpanswered Jeferson Assis 2,719 -
-1
votes1
answer1673
viewsA: PHP connection problems with Mysql.(Access denied for user)
Tries to give the user access remotely GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'YOUR_PASS' WITH GRANT OPTION; FLUSH PRIVILEGES;
-
2
votes2
answers63
viewsA: Date formatting is changing its parameters
Use the class DateTime to do the formatting: $data = DateTime::createFromFormat('d/m/Y', $data); return $data->format('Y-m-d')…
-
3
votes1
answer338
viewsA: Abort an Ajax request
Just reverse the order, the way you did, the beforeSend performs previously but it will not wait for the callback modal. function atualizaStatus(sel, id) { var $status = sel.value; var $idAluno =…
-
1
votes2
answers52
viewsA: Query brings data ignoring $conditions
You’re comparing date to date LIKE, in which case no record will return to you, as no record is equal to the date you are seeking. When buying a date of a particular day you can use >= and <=,…
cakephpanswered Jeferson Assis 2,719 -
0
votes1
answer27
viewsA: using cakephp 2x push array_push
Like the example you quoted, you’re creating a array with several items, to get the result you want just assign the value to your variable $this->request->data['Curso'] =…
-
1
votes2
answers68
viewsA: callback afterFind
Analyzing your code I saw that you use the method query() of the model. $despesas=$this->Despesa->query("select * from despesas where data_despesa like '%$this->dataDespesa%'"); When you…
cakephpanswered Jeferson Assis 2,719 -
3
votes1
answer68
viewsA: Protecting the form against invasion
Like @Marco said, using the PDO statement Example: $pdo = new PDO("mysql:host=mysql.seudominio.com.br;dbname=baseDeDados", "Usuario", "Senha"); $statement = $pdo->prepare("Insert into tabela…
phpanswered Jeferson Assis 2,719 -
3
votes1
answer57
viewsA: Select a product by establishment in mysql database!
You can use the group by, would look something like this SELECT * FROM produto GROUP BY ID_estab Edit If you want to display 1 random product from each establishment SELECT p.* FROM (SELECT * FROM…
-
0
votes3
answers66
viewsA: How to use a string from the database
You can use the json_decode() as per @Raylan’s reply, below is an example: $stringBanco = '{ "key":"save", "user":"1", "season":"2016", "week201549": { "bloco":"Microciclo", "day05122015":{…
-
1
votes2
answers147
viewsA: Popular View with JSON
First you need to fix your return, today it is returning an object and instead of a array containing several objects Instead of this return: { "titulo1": "Silvio Santos Ipsum", "texto1": "Ma vai pra…
-
2
votes4
answers352
viewsA: What is the second parameter of array_keys for?
Serves to filter the indexes that will be returned - According to the documentation Parameters input An array containing keys to be returned. search_value If specified, then only keys containing…
phpanswered Jeferson Assis 2,719 -
7
votes2
answers1432
viewsA: How to use fonts on my Site?
You can import the font into your project using CSS @font-face { font-family: 'museo300'; src: url('../fonts/museo300-regular-webfont.eot'); src: url('../fonts/museo300-regular-webfont.eot?#iefix')…
-
0
votes2
answers1278
viewsA: Select with Inner Join with Cakephp
With JOIN's Cakephp places values inside their respective objects. Probably your username is inside the object User: $post->user->username Give a pr() in its object $post so that it displays…
-
3
votes3
answers654
viewsA: How to loop inside an image folder and resize them?
You can use the function scandir() or the function glob() Glob() foreach (glob("*.jpg") as $arquivo) { $nameWithoutExtensionJPG = str_replace('.jpg', '', $arquivo); resize_and_crop($arquivo,…
-
1
votes1
answer137
viewsA: How to Save Form Data to DB with Cakephp
You can check if a post is coming and redeem the data sent by the form If you are using the Cakephp 3.0, add in the first line of your controller after the <?php use Cake I18n Time;…
-
3
votes2
answers3439
viewsA: Warning: array_push() expects Parameter 1 to be array, null Given in
Change your method preencheRodada round-class //PREENCHE O ARRAY public function preencheRodada(Partida $partida) { array_push($this->partidas, $partida); } Also change your method getRodada…
phpanswered Jeferson Assis 2,719 -
0
votes2
answers102
viewsA: Push notification via an array
You need to send one notification at a time. Loop the tokens and send them individually. You can use this lib to facilitate apns-php…
-
1
votes2
answers378
viewsA: Separate string from end to start with substr php
You can use the str_replace after picking up the string from the end with the substr trim(str_replace(substr($value, -7), '', $value)) Results: Emirates Air Canada Lan Airlines Obs: change the…
phpanswered Jeferson Assis 2,719 -
5
votes4
answers3932
viewsA: How to align 7 elements on the same line?
You can add the class col-xs-12, but it has to correct because its class #home-especialiadade .col-sm-2 this over her. Adiona media query for your class #home-especialdiade .col-sm-2: @media…
-
0
votes3
answers785
viewsA: file_exists php function - relative and absolute path
When you use file_exists("model/persistence/dao/dao_config/{$name}.ini") it will fetch from the location where the file. You can set a constant for the root folder define("DOCUMENT_ROOT",…
-
4
votes2
answers1323
viewsA: PHP and Javascript - Disable a Submit button if textarea is empty
Javascript-enabled Just add the ID to your button, and change your onkeyup of textarea for onkeyup="javascript: doSomething(this)" function doSomething(input) {…
-
2
votes1
answer834
viewsA: PHP Curl Upload Images
You can use the curl_file_create(), you do not need to upload to the server to then send by cURL, you can send direct only using this function. $post[$key] = curl_file_create($file['tmp_name'],…
-
0
votes2
answers306
viewsA: How to set flash in CAKEPHP view?
Since you didn’t specify which version, I’m complementing the answer from Claytinho In the version 2.x from Cakephp // In the view. echo $this->Session->flash(); In the version 3.x from…
cakephpanswered Jeferson Assis 2,719 -
0
votes1
answer47
viewsA: Script execution after clicking a link
You can make a redirect to the reference page using the $_SERVER['HTTP_REFERER'] After making your logical add the product in the section just redirect header('Location: '.$_SERVER['HTTP_REFERER']);…