prepare("SELECT ROUND(AVG(R1.rating),1) as averageRating FROM rating R1 RIGHT JOIN (SELECT MAX(R2.timestamp) AS timestamp FROM rating R2 GROUP BY R2.username) R2 ON R1.timestamp=R2.timestamp WHERE post_id=$post"))
{
$sql->execute();
$sql->bind_result($averageRating);
while ($sql->fetch()){}}
//ocena uzytkownika
if(!empty($_SESSION['user'])){
$user=$_SESSION['user'];
if ($sql = $mysqli->prepare("SELECT rating FROM rating WHERE post_id=$post AND username='$user'"))
{
$sql->execute();
$sql->bind_result($userRating);
while ($sql->fetch()){}} }
$trash = '';
if ($sql = $mysqli->prepare("SELECT * FROM post WHERE post_id =$post"))
{
$sql->execute();
$sql->bind_result($post_id,$trash,$title,$description,$main,$image,$date,$mod_date);
while ($sql->fetch())
{ ?>
close();
}
else die( "Błąd w zapytaniu SQL! Sprawdź kod SQL w PhpMyAdmin." );
if ($sql = $mysqli->prepare("SELECT comments.comment_id, comments.post_id, comments.username, comments.tekst, comments.data_dodania, comments.data_modyfikacji, user.user_id FROM comments LEFT JOIN user ON comments.username=user.username WHERE post_id =$post ORDER BY comment_id"))
{
$sql->execute();
$sql->bind_result($comment_id,$post_id,$username,$tekst,$data_dodania, $data_modyfikacji, $user_id); ?>
Komentarze
fetch())
{ ?>
close();
$mysqli->close();
} ?>
Dodaj komentarz: