troubleshooting Question

not able to connect to database

Avatar of Wayeel Cade
Wayeel Cade asked on
25 Comments6 Solutions195 ViewsLast Modified:
I  have a html form which is connected to be php file and inserts data into sql.
my issue is i want to submit multiple text boxes with the same name and insert into database.
i don't know how to loop it through.

html file
<form action="insert.php" method="post"  >
 <select id="drop" name="time">
               <option value = "8:30-12:30">8:30-12:30</option>
               <option value = "12:45-1:45">12:45-1:45</option>
               <option value = "2:00-6:00">2:00-6:00</option>
 <td> <input type="text" name="level" id="level">
 <td><input type="text" name="room" id="Room">
 <td> <input type="text" name="level" id="level">
 <td><input type="text" name="room" id="Room">
      <td><input type="submit" name="submit" value="Submit form"></td>

$time = mysqli_real_escape_string($link, $_REQUEST['time']);
$level = mysqli_real_escape_string($link, $_REQUEST['level']);
$room = mysqli_real_escape_string($link, $_REQUEST['room']);

$sql = "INSERT INTO april (time, level, room) VALUES ('$time', '$level', '$room')";
if(mysqli_query($link, $sql)){
    echo "Records added successfully.";
} else{
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
// close connection

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 6 Answers and 25 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 6 Answers and 25 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros