Update button in bootstrap modal werkt niet

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Brecht S

Brecht S

27/05/2015 13:50:02
Quote Anchor link
Ik heb een bootstrap modal die een id ophaalt uit een mysql database.
Die heeft bijhorende velden die getoond worden in de modal.
Tot hier gaat alles goed.
Nu wil ik een update knop (opslaan na edit) maar dan sluit de modal gewoon af dus er gebeurd geen update in mysql. Ik heb nog geen code geschreven voor die update knop omdat ik niet zeker ben dat die op de booking-ajax file moet staan of op de booking file?

Tabel op booking.php:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<table width="100%">
  <tr>
    <th align="center">Datum</th>
    <th align="center">Uur</th>
    <th align="center">Couverts</th>
    <th align="center">Acties</th>
  </tr>
                            
<?php
         $sql
= "SELECT * FROM cal_reservatie WHERE gastid = '$gastid' AND datum >= CURRENT_DATE";
         $res = mysql_query($sql) or die (mysql_error());
         while($row = mysql_fetch_assoc($res)) {
?>


  <tr>
    <td align="center" style="padding:5px;"><?php echo $row['datum']; ?></td>
    <td align="center" style="padding:5px;"><?php echo $row['uur']; ?></td>
    <td align="center" style="padding:5px;"><?php echo $row['couverts']; ?></td>
    <td align="center" style="padding:5px;"><button type="button" class="btn btn-info btn-xs showmodal" data-toggle="modal" data-target="#myModal" id='<?php echo $row['id']; ?>'>Wijzigen</button></td>
  </tr>
    
<?php
         }
?>


</table>


javascript op booking.php:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<script>
$(".showmodal").click(function()
{  
    var essay_id = $(this).attr('id');

    $.ajax({
        cache: false,
        type: 'POST',
        url: 'booking-ajax.php',
        data: 'EID='+essay_id,
        success: function(data)
        {
            $('#myModal').show();
            $('#modalContent').show().html(data);
        }
    });
});
</script>


Modal op booking.php:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Modal Header</h4>
      </div>
      <div class="modal-body">
        <div id="modalContent" style="display:none;">

        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>


booking-ajax.php file:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?
$id
= $_POST['EID'];

require ('config.php');
    
         $conn = mysql_connect($host,$user,$pass) or die (mysql_error());
         mysql_select_db($dbnm) or die (mysql_error());

         $sql = "SELECT * FROM cal_reservatie WHERE id = '$id'";
         $res = mysql_query($sql) or die (mysql_error());
         while($row = mysql_fetch_assoc($res)) {
?>



                      <form role="form" class="form-horizontal" method="post">
                                
                                <div class="form-group-separator"></div>
                                
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">Datum</label>
                                    <div class="col-sm-9">
                                        <div class="input-group">
                                            <input type="text" name="datum" class="form-control" value="<?php echo $row['datum']; ?>">
                                        </div>
                                    </div>
                                </div>
                                
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">Uur</label>
                                    <div class="col-sm-9">
                                        <div class="input-group">
                                            <input type="text" name="datum" class="form-control" value="<?php echo $row['uur']; ?>">
                                        </div>
                                    </div>
                                </div>
                                
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">Aantal pers</label>
                                    <div class="col-sm-9">
                                        <div class="input-group">
                                            <input type="text" name="datum" class="form-control" value="<?php echo $row['couverts']; ?>">
                                        </div>
                                    </div>
                                </div>
                                
                                <button type="submit" class="btn btn-info btn-xs" id="">Opslaan</button>

                       </form>        
  






<?php
         }



?>
 
Er zijn nog geen reacties op dit bericht.



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.