<?php

$clause='1=1';

$field='';

$value='';

if($_a=='select'):

    if(isset($etat)){

        $clause=" and etat='$etat";

    }

    if(isset($profil)){

        $clause=" and profil='$profil";

    }

    $sql="select * from user where $clause";

    echo json_encode(rows($sql));

endif;

if($_a=='get'):

    $sql="select * from user where id='$id'";

    echo json_encode(row($sql));

endif;

if($_a=='login'):

    $sql="select * from user where pseudo='$pseudo' and pwd='$pwd'";

    echo json_encode(row($sql));

endif;

if($_a=='delete'):

    $sql="delete from user where id='$id'";

    execute($sql);

endif;

if($_a=='update'):

    $field="pseudo='$pseudo',pwd='$pwd',profil='$profil',etat='$etat'";

    $sql="update user set $field where id='$id'";

    execute($sql);

endif;

if($_a=='insert'):

    $field="pseudo,pwd,profil,etat";

    $value="'$pseudo','$pwd','$profil','$etat'";

    $sql="insert into user($field) values($value)";

    echo execute($sql);

endif;