Jump to content

hgkhkhk

Members
  • Content count

    11
  • Joined

  • Last visited

Community Reputation

0 Neutral

About hgkhkhk

  • Rank
    Member
  1. hgkhkhk

    PHP and CSS- how to style comment site

    @requinix Thank you so much for your help. I have done everything as you explained above and have also managed to solve the styling problem. Your help is appreciated,
  2. I am building a comment section for my system. While it is working successfully, I cannot seem to style the comments the way I want to. All the comments appear at the very left side of the screen. Essentially I want to bring them to the center, color the username, and maybe put a border around the username and comments. I have tried everything such as using span classes and div classes, but nothing is working. If someone could please tell me where to put the span or div classes, I would appreciate it. Thank you. <?php if($_POST) { $name = $_POST['name']; $content = $_POST['commentContent']; $handle = fopen("comments.html","a"); fwrite($handle,"<b>" . $name . "</b>:<br/>" . $content . "<br/><br>"); fclose($handle); } ?> <!doctype html> <html> </head> <link rel="stylesheet" type="text/css" href="commentstyle.css"> <link rel="icon" href="Icon.jpg"> <title>Comment</title> </head> <body> <div class="header"> <img class="icon" src="Icon.jpg"> <div class="search">Comment </div> </div> <a href="homepage.php"><span class="home">Homepage</span></a> <div class="select">View comments</div> <br> <?php include "comments.html"; ?> <hr> <div class="box"> <form action = "" method = "POST"> Name:<br> <input type = "text" name = "name"><br/> Comment: <textarea rows = "10" cols = "30" name = "commentContent"></textarea><br/> <input type = "submit" value = "Submit"><br/> </form> </div> </body> </html>
  3. I have managed to solve the problem. Thanks to anyone for trying to help.
  4. I have built a search engine for my booking system. It works properly but the only issue I cannot resolve is how to display a "no results" message if nothing has been found in the system. I tried putting an }else{ echo 'no results'; } at the end the very end of the code, but when results are found, it still displays the "no results" message. Does anyone know where I can insert this line to ensure that "no results" does not show up when results actually turn up and to ensure it only shows, when no actual results have been found? Thank you. <?php $server="localhost"; $username="root"; $password=""; $dbname="equipment"; $conn=mysqli_connect($server,$username,$password,$dbname); $server="localhost"; $username="root"; $password=""; $dbname="qmb_ground_floor"; $conn2=mysqli_connect($server,$username,$password,$dbname); $server="localhost"; $username="root"; $password=""; $dbname="qmb_level_01"; $conn3=mysqli_connect($server,$username,$password,$dbname); $server="localhost"; $username="root"; $password=""; $dbname="qmb_level_02"; $conn4=mysqli_connect($server,$username,$password,$dbname); ?> <!doctype html> <html> <head> <link rel="stylesheet" type="text/css" href="resultsstyle.css"> <link rel="icon" href="Icon.jpg"> <title>Search</title> </head> <body> <div class="header"> <img class="icon" src="Icon.jpg"> <div class="search">Search </div> </div> <div class="select">Results </div> <?php if (isset($_POST['submit-search'])){ $search=mysqli_real_escape_string($conn,$_POST['search']); $sql="SELECT * FROM bookings WHERE equipment LIKE'%$search%' OR start_time LIKE '%$search%'OR end_time LIKE '%$search%'OR selected_date LIKE '%$search%'"; $result=mysqli_query($conn, $sql); $queryResult=mysqli_num_rows($result); if(empty($_POST['search'])){ echo '<span class="empty">Search box was empty. Please try again.</span>'; }else{ if($queryResult>0){ while($row=mysqli_fetch_assoc($result)){ echo " <span class='e'>Equipment: <span class='first'>".htmlspecialchars($row['equipment'])."</span></span><br> <span class='bd'>Booking Date: <span class='second'>".htmlspecialchars($row['selected_date'])."</span></span><br> <span class='st'>Start Time: <span class='third'>".htmlspecialchars($row['start_time'])."</span></span><br> <span class='et'>End Time: <span class='fourth'>".htmlspecialchars($row['end_time'])."</span></span><br> <span class='n'>Notes: <span class='fifth'>".htmlspecialchars($row['notes'])."</span></span><br><br><br><br> "; } } $search=mysqli_real_escape_string($conn2,$_POST['search']); $sql="SELECT * FROM bookings2 WHERE room LIKE'%$search%' OR start_time LIKE '%$search%'OR end_time LIKE '%$search%'OR selected_date LIKE '%$search%'"; $result=mysqli_query($conn2, $sql); $queryResult=mysqli_num_rows($result); if($queryResult>0){ while($row=mysqli_fetch_assoc($result)){ echo " <span class='e'>Room: <span class='first'>".htmlspecialchars($row['room'])."</span></span><br> <span class='bd'>Booking Date: <span class='second'>".htmlspecialchars($row['selected_date'])."</span></span><br> <span class='st'>Start Time: <span class='third'>".htmlspecialchars($row['start_time'])."</span></span><br> <span class='et'>End Time: <span class='fourth'>".htmlspecialchars($row['end_time'])."</span></span><br> <span class='n'>Notes: <span class='fifth'>".htmlspecialchars($row['notes'])."</span></span><br><br><br><br> "; } } $search=mysqli_real_escape_string($conn3,$_POST['search']); $sql="SELECT * FROM bookings3 WHERE room LIKE'%$search%' OR start_time LIKE '%$search%'OR end_time LIKE '%$search%'OR selected_date LIKE '%$search%'"; $result=mysqli_query($conn3, $sql); $queryResult=mysqli_num_rows($result); if($queryResult>0){ while($row=mysqli_fetch_assoc($result)){ echo " <span class='e'>Room: <span class='first'>".htmlspecialchars($row['room'])."</span></span><br> <span class='bd'>Booking Date: <span class='second'>".htmlspecialchars($row['selected_date'])."</span></span><br> <span class='st'>Start Time: <span class='third'>".htmlspecialchars($row['start_time'])."</span></span><br> <span class='et'>End Time: <span class='fourth'>".htmlspecialchars($row['end_time'])."</span></span><br> <span class='n'>Notes: <span class='fifth'>".htmlspecialchars($row['notes'])."</span></span><br><br><br><br> "; } } $search=mysqli_real_escape_string($conn4,$_POST['search']); $sql="SELECT * FROM bookings4 WHERE room LIKE'%$search%' OR start_time LIKE '%$search%'OR end_time LIKE '%$search%'OR selected_date LIKE '%$search%'"; $result=mysqli_query($conn4, $sql); $queryResult=mysqli_num_rows($result); if($queryResult>0){ while($row=mysqli_fetch_assoc($result)){ echo " <span class='e'>Room: <span class='first'>".htmlspecialchars($row['room'])."</span></span><br> <span class='bd'>Booking Date: <span class='second'>".htmlspecialchars($row['selected_date'])."</span></span><br> <span class='st'>Start Time: <span class='third'>".htmlspecialchars($row['start_time'])."</span></span><br> <span class='et'>End Time: <span class='fourth'>".htmlspecialchars($row['end_time'])."</span></span><br> <span class='n'>Notes: <span class='fifth'>".htmlspecialchars($row['notes'])."</span></span><br><br><br><br> "; } } } } ?> </div> </body> </html>
  5. I am trying to prevent a booking (record from being inserted) based on the number of people attending a room. So in this case,a specific room cannot be booked if more than a certain number of people are attending. For example, I have a field called 'people' in the database. Attached to this is a dropdown list containing dropdown values of 1,2,3,4,5,6,7,8,9,10. (The number of people attending.) I also have a field called 'room' in the database. Attached to this is also a dropdown list containing the values 'room a', 'room b' and 'room c.' The user must select a room (either 'room a' 'room b' 'room c') and has to select the number of people attending (either 1, 2, 3, 4, 5, 6 ,7, 8, 9,10) How would I prevent 'room a' from being booked(record inserted) if more than 7 people are selected from the dropdown list? Thank you.
  6. Hi. I have managed to solve the problem. Thanks to everyone for helping.
  7. @requinix- selected_date is the field in the database- used to store the date which the user has selected from the calendar. I used the following variable to be store the date. $eventdate=$month."/".$day."/".$year; The $eventdate variable is then inserted into the selected_date field in the bookings table in the database.
  8. @requinix I tried doing the following, but what ended up happening is that no bookings were allowed to be made. $sql="SELECT * FROM bookings WHERE selected_date AND start_time < end_time AND end_time>start_time"; $result= mysqli_query($dbconnection, $sql); $results=mysqli_num_rows($result); if($results>0) { echo "<span class='no'> Error </span>"; }else{ //This code inserts the record $sqlinsert="insert into bookings (equipment,start_time,end_time,notes,selected_date,date_added) values ('".$equipment."','".$start."','".$end."','".$notes."','".$eventdate."',now())"; $resultinsert=mysqli_query($dbconnection,$sqlinsert); if($resultinsert){ echo "<span class='go'> Booking was successful </span>"; } What I am building is a calendar. Yes, bookings are not allowed to span multiple days. The user clicks a date and then has to select an equipment from a drop down list along with the booking times (also from drop down lists- start time and end time have their own drop down lists.) So if the user has selected 12.00 to 18.00 and then another user tries booking the same equipment on the same day from 14.00 to 15.00 (obvious time clash) the system unfortunately still goes ahead and books the second user's request. I just don't know what to do to stop this from happening.
  9. I have tried everything to prevent this scenario from happening, but everything has failed. I would be very grateful if anyone could help with this scenario. If someone has booked an equipment on a certain day between 00:00 and 06.00, then someone tries to book the same equipment on the same day between 01:00 and 05:00, how do I stop this from happening? No matter what I do, the system still inserts a record into the database.Here is the code I am using: <?php if(isset($_GET['add'])){ $equipment=$_POST['equipment']; $start=$_POST['start']; $end=$_POST['end']; $notes=mysqli_real_escape_string($dbconnection, $_POST['notes']); $eventdate=$month."/".$day."/".$year; //This code inserts the record $sqlinsert="insert into bookings (equipment,start_time,end_time,notes,selected_date,date_added) values ('".$equipment."','".$start."','".$end."','".$notes."','".$eventdate."',now())"; $resultinsert=mysqli_query($dbconnection,$sqlinsert); if($resultinsert){ echo "<span class='go'> Booking was successful </span>"; } } ?> I have tried everything: from asking the database to check for records: "SELECT * FROM bookings WHERE selected_date BETWEEN start_time AND end_time"; to using conditional statements: if($start>$start && $end<$end) { echo "no"; } But nothing is working. Thank you to anyone who can help.
  10. Hi. This is my second question to the other one I posted (the one about the blank table cells.) I need help with this one. Does anyone know how to style a link in an individual table cell? Basically, I know that the rule is to use a:link in css. But this will not work as it would end up styling all the links within the calendar. What I want to do is to simply change the color of all the dates that fall under Sunday to be red, while leaving the other dates of the calender to be black. I posted this question on stackoverflow with the code. Thank you to anybody who can help. https://stackoverflow.com/questions/46990655/event-calender-php-how-to-style-link-in-individual-table-cell
  11. HI there. I am really stuck with this one and would appreciate any genuine help. I am creating an event calendar using with the help of a tutorial. However, what I need help with is to be able to add the necessary blank white cells after the last date of the month to fill the calendar. I posted this question on stackoverflow with the code. I appreciate any help and feedback. Thank you. https://stackoverflow.com/questions/46984754/event-calendar-php-how-to-create-blank-cells-after-the-last-date-of-the-month
×

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.