I want use query for "SELECT" with a condition "WHERE name = $name" and it's for the case GET not POST, so i tried this in my alloy:
$.name.setText(Alloy.Globals.auxiliar); var sendit = Ti.Network.createHTTPClient({ onload: function(e){ Alloy.Globals.loading.hide(); var json = this.responseText; var response = JSON.parse(json); $.stateConextion.setText("Aviso actualizado."); $.notice.setText(response[0].notice); Ti.API.info("cargamos"); }, onerror: function(e){ Alloy.Globals.loading.hide(); var dialog = Ti.UI.createAlertDialog({ cancel: 0, buttonNames: ['Aceptar'], message: 'Error de Conección', title: "Error" }); dialog.addEventListener('click', function(e){ if (e.index === e.source.cancel){ Ti.API.info('/////////////////////////////////////////////////////'); } }); dialog.show(); }, timeout:30000, }); sendit.open('GET', 'http://nosc.esy.es/readcurso.php'); var params = ({"id": "0" , "name": Alloy.Globals.auxiliar, "notice": $.notice.getText(),}); sendit.send(params); $.portal_curso.open();In my PHP file:
<?php $name = isset($_GET['name']) ? $_GET["name"] : ""; $notice = isset($_GET['notice']) ? $_GET["notice"] : ""; $json = array(); if($result = $mysqli->query("select * from database.mylist WHERE name ='".$name."'")) { while ($row=$result->fetch_assoc()) { $json[]=array( 'name'=>$row['name'], 'notice'=>$row['notice'] ); } } $result->close(); header("Content-Type: text/json"); echo json_encode(array( 'name' => $json , 'notice' =>$json)); $mysqli->close(); ?>*Where "name" attribute is primary key, so always return 1 row or 0 row.
My issues is: Why does this code always return 0 row? I did some bad in my code? Thanks