Skip to content
Extraits de code Groupes Projets
Valider f3150d59 rédigé par Julie Choquet's avatar Julie Choquet
Parcourir les fichiers

début like photo mais bug

parent 576b3471
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
.vote { .vote, .vote:focus, .vote:active {
float : left; float : left;
background-color: #52b3da; background-color: #52b3da;
color: white; color: white;
...@@ -47,7 +47,9 @@ ...@@ -47,7 +47,9 @@
border-color:#66CC33; border-color:#66CC33;
} }
.glyphicon-send {
color : white;
}
.btn-circle span { padding-right: 6px; } .btn-circle span { padding-right: 6px; }
.tab-content { .tab-content {
...@@ -63,3 +65,7 @@ img { ...@@ -63,3 +65,7 @@ img {
margin-left: auto; margin-left: auto;
max-height: 400px; max-height: 400px;
} }
.nav-tabs a, .nav-tabs a:hover{
color:black;
}
\ No newline at end of file
...@@ -62,6 +62,10 @@ $(document).ready(function (){ ...@@ -62,6 +62,10 @@ $(document).ready(function (){
{ {
$("#like").attr("disabled", true); $("#like").attr("disabled", true);
} }
else
{
$("#nbr_like").attr("idphoto", idphoto);
}
} }
else else
...@@ -71,7 +75,33 @@ $(document).ready(function (){ ...@@ -71,7 +75,33 @@ $(document).ready(function (){
} }
}); });
$('#like').click(function () {
var nombre = $("#nbr_like").text();
var idphoto = $("#nbr_like").attr("idphoto");
$.ajax({
type:'POST',
url:'script_like.php',
data:"nombre="+nombre+"&idphoto="+idphoto,
success:function(msg) {
if(msg == "OK")
{
$("#like").attr("disabled", true);
nombre = nombre + 1;
$("#nbr_like").html(nombre);
}
}
});
});
}); });
}); });
\ No newline at end of file
...@@ -64,8 +64,8 @@ ...@@ -64,8 +64,8 @@
<!-- fichier css perso --> <!-- fichier css perso -->
<link rel="stylesheet" href="css/menu.css"> <link rel="stylesheet" href="css/menu.css">
<link rel="stylesheet" href="css/mes_posts.css"> <link rel="stylesheet" href="css/mes_posts.css">
<link rel="stylesheet" type="text/css" href="css/modal.css">
<link rel="stylesheet" type="text/css" href="css/buttonLink.css"> <link rel="stylesheet" type="text/css" href="css/buttonLink.css">
<link rel="stylesheet" type="text/css" href="css/modal.css">
</head> </head>
......
...@@ -61,9 +61,9 @@ echo '</div>'; ...@@ -61,9 +61,9 @@ echo '</div>';
echo '</div>'; echo '</div>';
echo '<div class="modal-footer">'; echo '<div class="modal-footer">';
echo '<button class="btn btn-primary vote" data-toggle="tooltip" title="Vote pour la photo la plus trash">Trash<span class="badge trash">0</span></button>'; echo '<button class="btn btn-primary vote" data-toggle="tooltip" title="Vote pour la photo la plus trash">Trash<span class="badge">0</span></button>';
echo '<button class="btn btn-primary vote" data-toggle="tooltip" title="Vote pour la photo où ça pécho sec">Love<span class="badge love">0</span></button>'; echo '<button class="btn btn-primary vote" data-toggle="tooltip" title="Vote pour la photo où ça pécho sec">Love<span class="badge">0</span></button>';
echo '<button class="btn btn-primary vote" data-toggle="tooltip" title="Photo de toute beauté" id="like">Like<span class="badge like">0</span></button>'; echo '<button class="btn btn-primary vote" data-toggle="tooltip" title="Photo de toute beauté" id="like">Like<span class="badge" id="nbr_like" idphoto="" >0</span></button>';
echo '</div>'; echo '</div>';
echo '</div>'; echo '</div>';
......
<?php
session_start();
$id = $_SESSION['login'];
$nombre = $_POST['nombre'];
$idphoto = $_POST['idphoto'];
$nombre = $nombre + 1;
function addLike($db, $idphoto, $id) {
$stmt = $db->prepare("INSERT INTO liker(idphoto, idutilisateur) VALUES (:idphoto,'$id')");
$stmt->bindParam(':idphoto', $idphoto);
return $stmt->execute();
}
function upCompteurLike($db, $idphoto, $val) {
$stmt = $db->prepare("UPDATE photo SET nblike='$val' WHERE idphoto=:id");
$stmt->bindParam(':id', $idphoto);
return $stmt->execute();
}
try{
/* Connexion à la base de données avec PDO */
$DB = new PDO("pgsql:host=localhost;dbname=projet_web", "postgres", "root");
$result = addLike($DB, $idphoto, $id);
if($result)
{
$done = upCompteurLike($DB, $idphoto, $nombre);
if($done)
{
echo "OK";
}
else
{
echo "erreur";
}
}
else
{
echo "erreur";
}
$DB = null;
}
catch(PDOException $e){
echo "Database Error";
}
?>
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter