wsrta Posted October 27, 2022 Share Posted October 27, 2022 The thing is I already asssociated the modal to the details which is the name,date,timestart,timeend but when I choose the second data to view it is still showing the first table data Quote Link to comment https://forums.phpfreaks.com/topic/315463-data-modal-pop-up/ Share on other sites More sharing options...
wsrta Posted October 27, 2022 Author Share Posted October 27, 2022 code for the confirm button <?php $sql = "SELECT * FROM studentrequest"; $result = mysqli_query($conn,$sql); if($result){ while($row = mysqli_fetch_assoc($result)){ $srequestid = $row['studentrequestid']; $studentid = $row['studentID']; $studentname = $row['studentName']; $roomnumber = $row['roomNumber']; $instructor = $row['instructor']; $dateuse = $row['dateUsed']; $ts = $row['timeStart']; $te = $row['timeEnd']; echo ' <tr> <th scope="row">'.$srequestid.'</th> <td>'.$studentid.'</td> <td>'.$studentname.'</td> <td>'.$roomnumber.'</td> <td>'.$instructor.'</td> <td>'.$dateuse.'</td> <td>'.$ts.'</td> <td>'.$te.'</td> <td> <button type="button" class="btn btn-outline-success" data-toggle="modal" data-target="# ">Confirm</a></button> <div class="modal fade" id="confirm" tabindex="-1" role="dialog" aria-labelledby="comfirms" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="confirms">Alert!</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> Are you sure you want to confirm this? <br><br> <h3>Details</h3> Name: '.$studentname.' <br> Room number: '.$roomnumber.' <br> Date use: '.$dateuse.' <br> Time start: '.$ts.' <br> Time end: '.$te.' <br> </div> Quote Link to comment https://forums.phpfreaks.com/topic/315463-data-modal-pop-up/#findComment-1601970 Share on other sites More sharing options...
mac_gyver Posted October 27, 2022 Share Posted October 27, 2022 6 minutes ago, wsrta said: id="confirm" ids must be unique throughout the html document. since each section has the same id, the popup code always displays the first section. you need to use a different selector in the javascript, either to operate on the current element, find the nearest element, or use unique and valid ids in the markup. posting all the code needed to reproduce the problem would allow someone here to help arrive at the simplest result. Quote Link to comment https://forums.phpfreaks.com/topic/315463-data-modal-pop-up/#findComment-1601971 Share on other sites More sharing options...
ginerjm Posted October 27, 2022 Share Posted October 27, 2022 modal? I see a sample of some output and a long stretch of code that doesn't do anything other than produce some html table output. Not well done either - a row with one heading element combined with data items is not proper syntax and I actually wonder what it would produce. And I see a button tag. What does that button actually do? It's not a submit and it doesn't trigger any JS so I'm lost. And if it were a submit, there is no form to tell it where to go. Quote Link to comment https://forums.phpfreaks.com/topic/315463-data-modal-pop-up/#findComment-1601972 Share on other sites More sharing options...
ginerjm Posted October 27, 2022 Share Posted October 27, 2022 Did some clean up of your code to get a better picture. And still don't see it $sql = "SELECT * FROM studentrequest"; // DON'T USE * $result = mysqli_query($conn,$sql); if($result) { while($row = mysqli_fetch_assoc($result)) { $srequestid = $row['studentrequestid']; $studentid = $row['studentID']; $studentname = $row['studentName']; $roomnumber = $row['roomNumber']; $instructor = $row['instructor']; $dateuse = $row['dateUsed']; $ts = $row['timeStart']; $te = $row['timeEnd']; echo "<tr> <th scope='row'>$srequestid</th> <td>$studentid</td> <td>$studentname</td> <td>$roomnumber</td> <td>'.$instructor.'</td> <td>'.$dateuse.'</td> <td>'.$ts.'</td> <td>'.$te.'</td> <td> <button type='button' class='btn btn-outline-success' data-toggle='modal' data-target='#'> Confirm </a> </button> <div class='modal fade' id='confirm' tabindex='-1' role='dialog' aria-labelledby='comfirms' aria-hidden='true'> <div class='modal-dialog' role='document'> <div class='modal-content'> <div class='modal-header'> <h5 class='modal-title' id='confirms'>Alert!</h5> <button type='button' class='close' data-dismiss='modal' aria-label='Close'> <span aria-hidden='true'>×</span> </button> </div> <div class='modal-body'> Are you sure you want to confirm this? <br><br> <h3>Details</h3> Name: $studentname <br> Room number: $roomnumber <br> Date use: $dateuse <br> Time start: $ts <br> Time end: $te <br> </div> You need: NEED A CLOSING BRACE FOR YOUR ROW PROCESSING NEED SOME CLOSING DIV TAGS NEED AN ENDING ROW TAG and an ending quote for all the html you have echoed. NEED TO MOVE THAT TH TAG TO ITS OWN ROW NEED TO CHANGE THE BUTTON TAG TO EITHER USE SOME JS CODE OR TO DO A SUBMIT AND IF IT'S TO BE A SUBMIT YOU NEED A FORM CREATED. Quote Link to comment https://forums.phpfreaks.com/topic/315463-data-modal-pop-up/#findComment-1601973 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.