I'm doing a job for the school, in which they ask me to do a "mini replica" of what would be twitter, so we can see data handling with php and so on. Well, I have reached the point of registering users, logging in and saving tweets in a database, but something as simple as showing these, because it does not work out. You see, I have two databases;
Database users: I keep the fields name, username, password and id, in that order. Database tweets where I keep: id of the tweet, text (content of the tweet), date (date it was published) and userId (id of the user who published the tweet), also, in that order.
Well, I have the following function, which is responsible for recovering the content of the tweets
function obtenirTuits(){
$conn = connectar();
$sqlTweets = "SELECT * FROM tweets";
$rowsTweets = $conn->query($sqlTweets);
$rowsTweets = $rowsTweets -> fetch();
if (!$rowsTweets){
echo "<br>"."<br>"."No hi ha tuits a mostrar!";
}else{
}
}
As we can see, if the variable $ rowsTweets has no content, it will show us that there are no tweets to show, instead, if not, it should show the following:
Posted by "user" at the "publication date" Content of the tweet
But I do not know how to do this, besides, I would have to give the option that "x" user could erase his tweet, appearing a button in the following way:
Posted by "user" at the "publication date" Remove tweet Content of the tweet
Let's see if anyone can give me a hand, please.