here is where i display all articles from the database.
<?php
$conn = mysqli_connect('localhost','root','','blog');
$sql = "SELECT a.id, a.image, a.titre, a.text, a.dateart, u.uidUsers, u.profilepic
FROM articles a, users u WHERE a.idUsers = u.idUsers GROUP BY id DESC";
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_array($result)){
echo"<br/>";
echo"<div class=\"contenue\">";
$strcut = substr($row['text'], 0, 260);
$desc = substr($strcut, 0, strrpos($strcut, ' ')).'...';
if($row['profilepic']==''){
echo"<a href=\"#\"><img style=\"=width:30px;height:30px;\" src='profile/defaultpic.png'> ".$row['uidUsers']."</a>";
echo"<label style=\"font-size:13px;\"> | Cet article a ete publie a ".$row['dateart']."</label>";
}else{
echo"<a href=\"#\"><img style=\"=width:30px;height:30px;\" src='profile/".$row['profilepic']."'> ".$row['uidUsers']."</a>";
echo"<label style=\"font-size:13px;\"> | Cet article a ete publie a ".$row['dateart']."</label>";
}
echo"<hr/>";
echo"<h3>".$row['titre']."</h3>";
echo"<img style=\"=width:200px;height:200px;\" src='images/".$row['image']."'>";
$url = "readingall.php?read=".$row['id']."";
echo"<p>".$desc."
<a href=readingall.php?read=".$row['id'].">Lire la suite</a>
</p>";
echo"<a href=\"\">J'aime</a> | <a href=\"#\">J'aime pas</a> | <a href=\"#\">Commentaire</a>";
echo"</div>";
}
?>
here is where i display the article whe the id from database = to id from the link
<?php include("head.inc.php");
$id = ($_GET['read']);
$idc = $id;
if(isset($_POST['poste'])){
$aaa = $_GET['$id'];
$con = mysqli_connect("localhost","root","");
mysqli_select_db($con,"blog");
$iduser = $_SESSION['userID'];
$date = date('H:i / d-m-y');
$pseudo = $_POST['pseudo'];
$commentaire = $_POST['commentaire'];
if(isset($_SESSION['userID'])){
$sql = "INSERT INTO commentaire (idUsers, textec, datec,id)
VALUES('$iduser','$commentaire', '$date','$idc')";
mysqli_query($con, $sql);
header("Location:index.php?upload=success");
exit();
} else{
$sql = "INSERT INTO commentaire (pseudo, textec, datec, id)
VALUES('$pseudo', '$commentaire', '$date', $idc)";
mysqli_query($con, $sql);
header("Location:index.php?upload=success");
}
}
?>
<br/><br/>
<link rel="stylesheet" href="styles/index.css">
<link rel="stylesheet" href="styles/affiche_art.css">
<link rel="stylesheet" href="styles/comments.css">
<body style="background-color:#e2e2e2;">
<div class="aff_art">
<?php
$conn = mysqli_connect('localhost','root','','blog');
$sql = "SELECT a.id, a.image, a.titre, a.text, a.dateart, u.uidUsers, u.profilepic
FROM articles a, users u WHERE a.idUsers = u.idUsers AND a.id = '$id'";
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_array($result)){
echo"<br/>";
echo"<div class=\"contenue\">";
if($row['profilepic']==''){
echo"<a href=\"#\"><img style=\"=width:30px;height:30px;\" src='profile/defaultpic.png'> ".$row['uidUsers']."</a>";
echo"<label style=\"font-size:13px;\"> | Cet article a ete publie a ".$row['dateart']."</label>";
}else{
echo"<a href=\"#\"><img style=\"=width:30px;height:30px;\" src='profile/".$row['profilepic']."'> ".$row['uidUsers']."</a>";
echo"<label style=\"font-size:13px;\"> | Cet article a ete publie a ".$row['dateart']."</label>";
}
echo"<hr/>";
echo"<h3>".$row['titre']."</h3>";
echo"<img style=\"=width:200px;height:200px;\" src='images/".$row['image']."'>";
echo"<p>".$row['text']."</p>";
echo"<a href=\"#\">J'aime</a>
| <a href=\"#\">J'aime pas</a>
| <a href=\"#\">Commentaire</a>";
echo"</div>";
echo"<br/>";
?>
<!-- code action commentaire-->
<?php
if(isset($_SESSION['userID'])){
echo'
<div class="contenue">
<div class="commentaire">
<form action="readingall.php" method="post">
<textarea name="commentaire" id="commentaire" rows="2" cols="50" placeholder="Commenter ici"></textarea>
<input type="submit" name="poste" id="poste" value="POSTE">
</form>
</div>
</div>
';
}else{
echo'
<div class="contenue">
<div class="droite">
<h5>Commenter en tant qu\'un visiteur</h5>
<form action="readingall.php" method="post">
<input type="text" name="pseudo" id="pseudo" placeholder="Pseudo">
<textarea name="commentaire" id="commentaire" rows="2" cols="5" placeholder="Commenter ici!"></textarea>
<button type="submit" name="poste" id="poste">POSTE</button>
</form>
</div>
<div class="gauche">
<h5>Connectez ou incrivez vous!</h5>
<form action="login.php" method="post">
<button type="submit">Connexion</button>
</form>
<br/>
<form action="ncomptee.php" method="post">
<button type="submit" name="button">Inscription</button>
</form>
</div>
</div>
';
}
}
?>
there is some french text, but i think that not gonna be a problem
i am from haiti.