Ejemplo n.º 1
0
//Vérification de la connexion
if ($_SESSION['user']['role'] != 1 && $_SESSION['user']['role'] != 2) {
    header('Location: ../index.php');
}
/*
//Edition article existant
if(isset($_GET['article'])){
	$article = editArticleById($_GET['article']);
}
*/
//Obtenir les catégories
$allCategorie = getCategorie();
//Nombre articles auteurs
$nbArticle = userArticlesCount($_SESSION['user']['id']);
//Obtenir articles auteur
$userArticle = getUserArticles($_SESSION['user']['id']);
var_dump($userArticle);
?>

<?php 
if ($userArticle) {
    ?>

<h1>Vos Articles (<?php 
    echo $nbArticle;
    ?>
)</h1>

<?php 
    foreach ($userArticle as $article) {
        ?>
Ejemplo n.º 2
0
function getUserArticles($idUser)
{
    $myDB = connectDB();
    $sql = 'SELECT * FROM articles WHERE id_utilisateur = ' . $idUser;
    $articleReq = $myDB->query($sql);
    $verif = getUserArticles($idUser);
    disconnectDB($myDB);
    if ($verif != 0) {
        $i = 1;
        while ($myData = $articleReq->fetch()) {
            $userArticle[$i]['id'] = $myData['id_article'];
            $userArticle[$i]['date'] = $myData['date'];
            $userArticle[$i]['titre'] = $myData['Titre'];
            $userArticle[$i]['text'] = $myData['text'];
            $i++;
        }
        return $userArticle;
    } else {
        return null;
    }
}