Jump to content

aleX2

Members
  • Posts

    21
  • Joined

  • Last visited

aleX2's Achievements

Member

Member (2/5)

0

Reputation

  1. Thank you for suggestions how to create tables... I will use that in the future.
  2. It's done... Table: users user_id int(11) firstname varchar(100) email varchar(50) password varchar(300) status enum('admin','user') Table: comment comment_id int(11) user_id int(11) news_id int(11) firstname varchar(50) comment text time timestamp Table: news news_id int(11) title varchar(200) text text category varchar(20) time timestamp author varchar(50)
  3. Diff between name(is for first and lastname) and username{nickname). For text fields they told us to put text and not varchar.So we don't have to worry about word limit. Thanks for suggestion, it is a good one. In school they told us to use timestamp. As I told you I am a begginer and I don't know a lots of things. That is why I came here in first place.
  4. Table: comment comment_id int(11) user_id int(11) news_id int(11) name varchar(50) comment text time timestamp Table: users user_id int(11) name varchar(100) email varchar(50) username varchar(50) password varchar(300) status enum('admin','user') Table: news news_id int(11) title varchar(200) text text category varchar(20) time timestamp author varchar(50)
  5. in users table is the real id of the person... news id just have the news id so I can show it in comment table. and I guess that I don't need the id of comment...just the id of person?
  6. users: id name email password status(admin or user) (sign up and log in) news:id(of the news), title, text, category, author(I am the author) comment: id(of comment), user_id(to see what user wrote the comment), newsid(to se on what news he wrote the comment), name(of the person), comment, time
  7. Yes, the real names of columns. In users table id is person's id, in comments table id is id of comment and user_id is person who wrote the comment.And id in news table is news id.Author is the person who wrote the news in my case is admin(me)
  8. They told me to expand so i can see what user on what news left the comment. It is a "newspaper" folder in mysql so I have: users table id, name, email, password, status comment table I have id, user_id, newsid, name, comment and time news table id, title, text, category, author Point is to show news and only logged in user can comment on that news.User can only delete the message that he wrote and admin can delete all messages.
  9. They told me to do this: "Only logged in users need to be able to write comments. It is necessary to keep the user id in the session. Expand the comment table with the user_id column to keep track of which user left the comment (you are taking the user id from the session). When scrolling through comments, it is necessary to compare whether the user id and the comment table match the user id from the session, if it matches, only then display the delete buttons." Well, I done the part that only logged in users are able to write a comment and I expanded table...But when it comes to write a match code I get lost.Or I don't write a code well or I don't put it in the right place.I don't know where is the problem.😰
  10. That is a problem...I know how to make delete button, but I don't know how to make it function well for user and admin.We still didn't got to js script part in classes.😒
  11. As I said I am a begginer...I don't know what I'm doing.😶 I don't know what I need to change.
  12. <?php session_start(); require_once("function.php"); require_once("class/DataB.class.php"); $conn = new DataB(); if(!$conn->connect()) { echo "Wrong DB connection!"; exit(); } if(isset($_POST['comment'])){ if(login()) { $id = $_SESSION['id']; $user_id = $_SESSION['user_id']; $status = $_SESSION['status']; } $query = "DELETE FROM comment WHERE user_id={$id}"; $conn->query($query); header("Location: deletecomment.php"); } ?> And this is a dcomm page
  13. <?php session_start(); require_once("function.php"); require_once("class/DataB.class.php"); $conn = new DataB(); if(!$conn->connect()) { echo "Wrong DB connection!"; exit(); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Delete Comment</title> <link rel="stylesheet" href="css/style.css"> </head> <body> <div id="container"> <?php require_once("nav.php"); if(login()) { $id = $_SESSION['id']; $query = "SELECT * FROM comment"; } $res = $conn->query($query); if($conn->num_rows($res) > 0){ while($row = $conn->fetch_assoc($res)){ ?> <div id="img"> <a href="dcomm.php?id=<?php echo $row['id'];?>"><img src="img/delete.png" title="DELETE COMMENT"></a> <p><b> Name: </b><br><?php echo $row['name'];?></p> <p><b> Comment: </b><br><?php echo $row['comment'];?></p> </div> <hr> <?php } }else{ echo "<h3>No comments!</h3>"; } ?> </div> </div> </body> this is delecomment page
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.