Condition : si 0 publication alors afficher erreur

Résolu
reverb94 Messages postés 106 Date d'inscription   Statut Membre Dernière intervention   -  
reverb94 Messages postés 106 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour à tous et à toutes,

Je suis actuellement sur la création d'une galerie d'art, avec un espace de publication de modification etc...

Une fois le membre inscrit, il peut avoir le choix d'accéder a la modification de publication,
mais lorsqu'un membre n'as pas encore publier d'oeuvre, j'aimerais effectué une condition qui affichera au membre en question, qu'il n'y a aucune publication d'effectuer sous son profil, et que pour modifier une oeuvre il doit déjà en publier une ^^,

sachant que les oeuvres de l'artiste s'affiche après des données envoyé par GET dans une autre page

voici mon code :

switch ($_GET['action']) {
	 
	 case "selection":
	 
	 $artiste_id = $_SESSION['membre_id'];
	 echo '<h3 class="textesimple">'."Séléctionnez une oeuvres".'</h3>';
$reponse=$bdd->prepare('SELECT oeuvre_id, artiste_id, titre_oeuvre, description_oeuvre, image_oeuvre, oeuvre_categorie, oeuvre_style, date_crea FROM oeuvre_artiste WHERE artiste_id= :artiste_id');
$reponse->bindValue(':artiste_id', $artiste_id, PDO::PARAM_INT);
$reponse->execute();
 while ($data=$reponse->fetch()) { 
 
 echo '<div id="ficheartistegal"><a href="./publication.php?s='.stripslashes(htmlspecialchars($data['oeuvre_id'])).'&action=modifier"><figure><img src="./images/oeuvres/'.stripslashes(htmlspecialchars($data['image_oeuvre'])).'" class="imgavatargal" alt="oeuvres artiste" /><figcaption><p class="boutonlien">'.stripslashes(htmlspecialchars($data['titre_oeuvre'])).'</p></figcaption></figure></a></div>';
 }
 
 $reponse->closeCursor();
	 
	 break;


j'ai tenté une condition du genre :

if ( (empty($data['oeuvre_id']))
{
echo '<p class="textesimple">'."Vous devez effectuer une publication pour accéder à l'espace de modification.".'</p>';
}


Merci pour votre aide et votre attention =)

2 réponses

Alain_42 Messages postés 5361 Date d'inscription   Statut Membre Dernière intervention   894
 
essayes comme cela:

....

$reponse->execute();
if($reponse->rowCount() >0){ //nombre de lignes trouvées pour cet artiste
	 while ($data=$reponse->fetch()) { 
	 
		echo '<div id="ficheartistegal"><a href="./publication.php?s='.stripslashes(htmlspecialchars($data['oeuvre_id'])).'&action=modifier"><figure><img src="./images/oeuvres/'.stripslashes(htmlspecialchars($data['image_oeuvre'])).'" class="imgavatargal" alt="oeuvres artiste" /><figcaption><p class="boutonlien">'.stripslashes(htmlspecialchars($data['titre_oeuvre'])).'</p></figcaption></figure></a></div>';
	 }
 }else{
	echo 'Vous n\'avez aucune oeuvre a modifier !';
 }
 
 $reponse->closeCursor();
 
 .....
1
reverb94 Messages postés 106 Date d'inscription   Statut Membre Dernière intervention   1
 
Salut à toi =), et un grand merci ^^

cette formule fonctionne parfaitement xD,

merci encore pour ton aide =).
0