Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

SELECT INTO ARRAY

General discussions related to php

Moderators: macek, egami, gesf

SELECT INTO ARRAY

Postby Joak190867 » Fri Feb 07, 2014 9:41 am

Hello guys!, I'm newbie in PHP, so .... please help me!!!!

I have a QUERY and I want to put the records into Array ... I have spent 3 days and I can't continue with my code


function redeem() {
// Check for required parameters
if (isset($_POST["id_cliente"]) && isset($_POST["id_sucursal"])) {
// Put parameters into local variables
$cliente = $_POST["id_cliente"];
$sucursal = $_POST["id_sucursal"];
$stmt = $this->db->prepare('SELECT id_arbitro FROM arbitro WHERE id_cliente =? AND id_sucursal =?') or die(mysqli_error($this->db));
$stmt->bind_param("ii", $cliente, $sucursal);
$stmt->execute();
//$stmt->bind_result($id_arbitro);
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$cuantos = count($result);
echo "$cuantos";

$registros = 0;
//This doesn't work too
/*while ($stmt->fetch()) {
$registros ++;
// Return unlock code, encoded with JSON
$result = array("id_arbitro" => $stmt,);
echo "$id_arbitro !";
}
*/
$stmt->close();
if ($registros < 0) {
sendResponse(400,"No existen arbitros con los parámetros recibidos");
return false;
}

//echo json_encode($result);
sendResponse(200, "FIN");
//printf("ERROR %s",$registros);
return true;
}
sendResponse(400, 'Invalid request');
return false;
}
Joak190867
New php-forum User
New php-forum User
 
Posts: 2
Joined: Fri Feb 07, 2014 9:32 am

Return to PHP General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.