开发者

problem with loops and fetchcolum in php?

I got an $arrayDirectoy variable which contains just 2 values, then I tried to pass that variable to a query in a for loop to retrieve the ids of each one, but It just echo me one id, and there are two ids, I dont know how to fix that, It just print me 1 id.

Example $arrayDirectory[] = {user1, user2};

it must echo 1 2 but开发者_如何学编程 just print me 1

for($i=0;$i<sizeof($arrayDirectory;$i++){ 
    $res[$i] = $obj->obtainID($arrayDirectory[$i]);

    echo $res[$i];

}

this is my obtainID method

public function obtainID($user){

        $conexion = $this->objConexion->configuracion();
        $query = "CALL sp_xxx('$user')";
        $stmt = $conexion->prepare($query);
        $stmt->execute();
        $resultado = $stmt->fetchColumn();
        return $res;
    }


try

foreach($arrayDirectory as $a)
{
 echo $obj->obtainID($a);
}

if this still do the same as ur for loop the problem will be something else

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜