3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); // Connect to the DB $link = mysqli_connect("localhost", "firstcor_frstuse", "{gV43i0VX@U}") or die("Error " . mysqli_error($link)); //include ('connect.php'); //$ID=$_GET["ID"]; $dep_rate_cat=$_GET["CAT"]; echo $dep_rate_cat; // store in the DB if(!empty($_POST['ok'])) { // first delete the records marked for deletion. Why? Because we don't want to process them in the code below if( !empty($_POST['delete_IDs']) and is_array($_POST['delete_IDs'])) { // you can optimize below into a single query, but let's keep it simple and clear for now: foreach($_POST['delete_IDs'] as $ID) { $sql = "DELETE FROM tblRates_balance WHERE ID=$ID"; $link->query($sql); } } // now, to edit the existing data, we have to select all the records in a variable. $sql="SELECT * FROM tblRates_balance ORDER BY ID where dep_rate_cat=$dep_rate_cat"; $result = $link->query($sql); // now edit them while($tblRates_balance = mysqli_fetch_array($result)) { // remember how we constructed the field names above? This was with the IDea to access the values easy now $sql = "UPDATE tblRates_balance SET dep_rate_cat=$dep_rate_cat, Min_Balance='".$_POST['Min_Balance'.$tblRates_balance['ID']]."', Interest_Rate='".$_POST['Interest_rate'.$tblRates_balance['ID']]."', Apy='".$_POST['Apy'.$tblRates_balance['ID']]."', sub_order='".$_POST['sub_order'.$tblRates_balance['ID']]."' WHERE ID='$tblRates_balance[ID]'"; $link->query($sql); } // (feel free to optimize this so query is executed only when a product is actually changed) // adding new if(!empty($_POST['Min_Balance'])) { foreach($_POST['Min_Balance'] as $cnt => $Min_Balance) { $sql = "INSERT INTO tblRates_balance (dep_rate_cat, Min_Balance, Interst_Rate, APY,sub_order) VALUES ('$dep_rate_cat','$Min_Balance', '".$_POST['Interest_rate'][$cnt]."', '".$_POST['APY'][$cnt]."','".$_POST['sub_order'][$cnt]." );"; $link->query($sql); } } } // select existing products here $sql="SELECT * FROM tblRates_balance ORDER BY dep_rate_cat"; $result = $link->query($sql); ?> <html> <head> <title>Simple example of dynamically adding rows with jQuery</title> <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.3.js"></script> </head> <body> <div style="width:90%;margin:auto;"> <h1>Simple example of dynamically adding rows with jQuery </h1> <form action="<? echo htmlentities($_SERVER['PHP_SELF']); ?>" method="POST"> <div ID="itemRows"> Minimum Balance: <input type="text" name="Minimum_Balance" size="30" /> Interest Rate: <input type="text" name="Interest_Rate" /> APY: <input type="text" name="APY" /> Order: <input type="text" name="sub_order" size="2"/> <input onClick="addRow(this.form);" type="button" value="Add row" /> (This row will not be saved unless you click on "Add row" first) <?php // let's assume you have the product data from the DB in variable called $tblRates_balances while($tblRates_balance = mysqli_fetch_array($result)): ?> <p ID="oldRow<?=$tblRates_balance['ID']?>"> <input type="text" name="dep_rate_cat<?=$tblRates_balance['dep_rate_cat']?>" size="4" value="<?=$tblRates_balance['dep_rate_cat']?> Minimum Balance: <input type="text" name="Min_Balance<?=$tblRates_balance['Min_Balance']?>" size="4" value="<?=$tblRates_balance['Min_Balance']?>" /> Interest Rate: <input type="text" name="Interest_rate<?=$tblRates_balance['Interest_Rate']?>" value="<?=$tblRates_balance['Interest_Rate']?>" /> APY: <input type="text" name="Apy<?=$tblRates_balance['Apy']?>" value="<?=$tblRates_balance['Apy']?>" /> Order: <input type="text" name="sub_order<?=$tblRates_balance['sub_order']?>" value="<?=$tblRates_balance['sub_order']?>" /> <input type="checkbox" name="delete_IDs[]" value="<?=$tblRates_balance['ID']?>"> Mark to delete</p> <?php endwhile;?> </div> <p><input type="submit" name="ok" value="Save Changes"></p> </form> </div> <script type="text/javascript"> var rowNum = 0; function addRow(frm) { rowNum ++; var row = '<p ID="rowNum'+rowNum+'">Minimum Balance : <input type="text" name="Min_balance[]" size="4" value="'+frm.add_Min_Balance.value+'"> Interest Rate: <input type="text" name="Interest_Rate[]" value="'+frm.add_Interest_Rate.value+'"> APY: <input type="text" name="Apy[]" value="'+frm.add_Apy.value+'"> Order: <input type="text" name="sub_order[]" value="'+frm.add_sub_order.value+'"> <input type="button" value="Remove" onclick="removeRow('+rowNum+');"></p>'; jQuery('#itemRows').append(row); frm.add_Min_Balance.value = ''; frm.add_Interest_Rate.value = ''; frm.add_Apy.value = ''; frm.add_sub_order.value = ''; } function removeRow(rnum) { jQuery('#rowNum'+rnum).remove(); } </script> </body> </html>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 128
Branch analysis from position: 24
2 jumps found. (Code = 46) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 45
Branch analysis from position: 33
2 jumps found. (Code = 77) Position 1 = 36, Position 2 = 44
Branch analysis from position: 36
2 jumps found. (Code = 78) Position 1 = 37, Position 2 = 44
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 88
Branch analysis from position: 88
2 jumps found. (Code = 44) Position 1 = 93, Position 2 = 53
Branch analysis from position: 93
2 jumps found. (Code = 43) Position 1 = 97, Position 2 = 128
Branch analysis from position: 97
2 jumps found. (Code = 77) Position 1 = 100, Position 2 = 127
Branch analysis from position: 100
2 jumps found. (Code = 78) Position 1 = 101, Position 2 = 127
Branch analysis from position: 101
1 jumps found. (Code = 42) Position 1 = 100
Branch analysis from position: 100
Branch analysis from position: 127
1 jumps found. (Code = 42) Position 1 = 179
Branch analysis from position: 179
2 jumps found. (Code = 44) Position 1 = 184, Position 2 = 142
Branch analysis from position: 184
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 142
2 jumps found. (Code = 44) Position 1 = 184, Position 2 = 142
Branch analysis from position: 184
Branch analysis from position: 142
Branch analysis from position: 127
Branch analysis from position: 128
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 93, Position 2 = 53
Branch analysis from position: 93
Branch analysis from position: 53
Branch analysis from position: 44
Branch analysis from position: 45
Branch analysis from position: 32
Branch analysis from position: 128
filename:       /in/g5Yc3
function name:  (null)
number of ops:  186
compiled vars:  !0 = $link, !1 = $dep_rate_cat, !2 = $ID, !3 = $sql, !4 = $result, !5 = $tblRates_balance, !6 = $Min_Balance, !7 = $cnt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 32767
          2        DO_ICALL                                                 
    4     3        INIT_FCALL_BY_NAME                                       'mysqli_connect'
          4        SEND_VAL_EX                                              'localhost'
          5        SEND_VAL_EX                                              'firstcor_frstuse'
          6        SEND_VAL_EX                                              '%7BgV43i0VX%40U%7D'
          7        DO_FCALL                                      0  $9      
          8        ASSIGN                                           ~10     !0, $9
          9      > JMPNZ_EX                                         ~10     ~10, ->16
         10    >   INIT_FCALL_BY_NAME                                       'mysqli_error'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0  $11     
         13        CONCAT                                           ~12     'Error+', $11
         14      > EXIT                                                     ~12
         15*       BOOL                                             ~10     <true>
    7    16    >   FETCH_R                      global              ~13     '_GET'
         17        FETCH_DIM_R                                      ~14     ~13, 'CAT'
         18        ASSIGN                                                   !1, ~14
    9    19        ECHO                                                     !1
   11    20        FETCH_IS                                         ~16     '_POST'
         21        ISSET_ISEMPTY_DIM_OBJ                         1  ~17     ~16, 'ok'
         22        BOOL_NOT                                         ~18     ~17
         23      > JMPZ                                                     ~18, ->128
   13    24    >   FETCH_IS                                         ~19     '_POST'
         25        ISSET_ISEMPTY_DIM_OBJ                         1  ~20     ~19, 'delete_IDs'
         26        BOOL_NOT                                         ~21     ~20
         27      > JMPZ_EX                                          ~21     ~21, ->32
         28    >   FETCH_R                      global              ~22     '_POST'
         29        FETCH_DIM_R                                      ~23     ~22, 'delete_IDs'
         30        TYPE_CHECK                                  128  ~24     ~23
         31        BOOL                                             ~21     ~24
         32    > > JMPZ                                                     ~21, ->45
   15    33    >   FETCH_R                      global              ~25     '_POST'
         34        FETCH_DIM_R                                      ~26     ~25, 'delete_IDs'
         35      > FE_RESET_R                                       $27     ~26, ->44
         36    > > FE_FETCH_R                                               $27, !2, ->44
   16    37    >   NOP                                                      
         38        FAST_CONCAT                                      ~28     'DELETE+FROM+tblRates_balance+WHERE+ID%3D', !2
         39        ASSIGN                                                   !3, ~28
   17    40        INIT_METHOD_CALL                                         !0, 'query'
         41        SEND_VAR_EX                                              !3
         42        DO_FCALL                                      0          
   15    43      > JMP                                                      ->36
         44    >   FE_FREE                                                  $27
   22    45    >   NOP                                                      
         46        FAST_CONCAT                                      ~31     'SELECT+%2A+FROM+tblRates_balance+ORDER+BY+ID+where+dep_rate_cat%3D', !1
         47        ASSIGN                                                   !3, ~31
   23    48        INIT_METHOD_CALL                                         !0, 'query'
         49        SEND_VAR_EX                                              !3
         50        DO_FCALL                                      0  $33     
         51        ASSIGN                                                   !4, $33
   26    52      > JMP                                                      ->88
   28    53    >   ROPE_INIT                                     3  ~36     'UPDATE+tblRates_balance+SET+dep_rate_cat%3D'
         54        ROPE_ADD                                      1  ~36     ~36, !1
         55        ROPE_END                                      2  ~35     ~36, '%2C+Min_Balance%3D%27'
         56        FETCH_DIM_R                                      ~39     !5, 'ID'
         57        CONCAT                                           ~40     'Min_Balance', ~39
         58        FETCH_R                      global              ~38     '_POST'
         59        FETCH_DIM_R                                      ~41     ~38, ~40
         60        CONCAT                                           ~42     ~35, ~41
         61        CONCAT                                           ~43     ~42, '%27%2C+Interest_Rate%3D%27'
         62        FETCH_DIM_R                                      ~45     !5, 'ID'
         63        CONCAT                                           ~46     'Interest_rate', ~45
         64        FETCH_R                      global              ~44     '_POST'
         65        FETCH_DIM_R                                      ~47     ~44, ~46
         66        CONCAT                                           ~48     ~43, ~47
         67        CONCAT                                           ~49     ~48, '%27%2C+Apy%3D%27'
         68        FETCH_DIM_R                                      ~51     !5, 'ID'
         69        CONCAT                                           ~52     'Apy', ~51
         70        FETCH_R                      global              ~50     '_POST'
         71        FETCH_DIM_R                                      ~53     ~50, ~52
         72        CONCAT                                           ~54     ~49, ~53
         73        CONCAT                                           ~55     ~54, '%27%2C+sub_order%3D%27'
         74        FETCH_DIM_R                                      ~57     !5, 'ID'
         75        CONCAT                                           ~58     'sub_order', ~57
         76        FETCH_R                      global              ~56     '_POST'
         77        FETCH_DIM_R                                      ~59     ~56, ~58
         78        CONCAT                                           ~60     ~55, ~59
         79        ROPE_INIT                                     3  ~63     '%27%0A%09%09WHERE+ID%3D%27'
   29    80        FETCH_DIM_R                                      ~61     !5, 'ID'
         81        ROPE_ADD                                      1  ~63     ~63, ~61
         82        ROPE_END                                      2  ~62     ~63, '%27'
         83        CONCAT                                           ~65     ~60, ~62
   28    84        ASSIGN                                                   !3, ~65
   31    85        INIT_METHOD_CALL                                         !0, 'query'
         86        SEND_VAR_EX                                              !3
         87        DO_FCALL                                      0          
   26    88    >   INIT_FCALL_BY_NAME                                       'mysqli_fetch_array'
         89        SEND_VAR_EX                                              !4
         90        DO_FCALL                                      0  $68     
         91        ASSIGN                                           ~69     !5, $68
         92      > JMPNZ                                                    ~69, ->53
   38    93    >   FETCH_IS                                         ~70     '_POST'
         94        ISSET_ISEMPTY_DIM_OBJ                         1  ~71     ~70, 'Min_Balance'
         95        BOOL_NOT                                         ~72     ~71
         96      > JMPZ                                                     ~72, ->128
   39    97    >   FETCH_R                      global              ~73     '_POST'
         98        FETCH_DIM_R                                      ~74     ~73, 'Min_Balance'
         99      > FE_RESET_R                                       $75     ~74, ->127
        100    > > FE_FETCH_R                                       ~76     $75, !6, ->127
        101    >   ASSIGN                                                   !7, ~76
   40   102        ROPE_INIT                                     5  ~79     'INSERT+INTO+tblRates_balance+%28dep_rate_cat%2C+Min_Balance%2C+Interst_Rate%2C+APY%2Csub_order%29+VALUES+%28%27'
        103        ROPE_ADD                                      1  ~79     ~79, !1
        104        ROPE_ADD                                      2  ~79     ~79, '%27%2C%27'
        105        ROPE_ADD                                      3  ~79     ~79, !6
        106        ROPE_END                                      4  ~78     ~79, '%27%2C+%27'
        107        FETCH_R                      global              ~82     '_POST'
        108        FETCH_DIM_R                                      ~83     ~82, 'Interest_rate'
        109        FETCH_DIM_R                                      ~84     ~83, !7
        110        CONCAT                                           ~85     ~78, ~84
        111        CONCAT                                           ~86     ~85, '%27%2C+%27'
        112        FETCH_R                      global              ~87     '_POST'
        113        FETCH_DIM_R                                      ~88     ~87, 'APY'
        114        FETCH_DIM_R                                      ~89     ~88, !7
        115        CONCAT                                           ~90     ~86, ~89
        116        CONCAT                                           ~91     ~90, '%27%2C%27'
        117        FETCH_R                      global              ~92     '_POST'
        118        FETCH_DIM_R                                      ~93     ~92, 'sub_order'
        119        FETCH_DIM_R                                      ~94     ~93, !7
        120        CONCAT                                           ~95     ~91, ~94
        121        CONCAT                                           ~96     ~95, '+%29%3B'
        122        ASSIGN                                                   !3, ~96
   41   123        INIT_METHOD_CALL                                         !0, 'query'
        124        SEND_VAR_EX                                              !3
        125        DO_FCALL                                      0          
   39   126      > JMP                                                      ->100
        127    >   FE_FREE                                                  $75
   47   128    >   ASSIGN                                                   !3, 'SELECT+%2A+FROM+tblRates_balance+ORDER+BY+dep_rate_cat'
   48   129        INIT_METHOD_CALL                                         !0, 'query'
        130        SEND_VAR_EX                                              !3
        131        DO_FCALL                                      0  $100    
        132        ASSIGN                                                   !4, $100
   50   133        ECHO                                                     '%0A%3Chtml%3E%0A%3Chead%3E%0A%09%3Ctitle%3ESimple+example+of+dynamically+adding+rows+with+jQuery%3C%2Ftitle%3E%0A%09%3Cscript+type%3D%22text%2Fjavascript%22+src%3D%22http%3A%2F%2Fajax.aspnetcdn.com%2Fajax%2FjQuery%2Fjquery-2.0.3.js%22%3E%3C%2Fscript%3E%0A%3C%2Fhead%3E%0A%0A%3Cbody%3E%0A%0A%3Cdiv+style%3D%22width%3A90%25%3Bmargin%3Aauto%3B%22%3E%0A%09%3Ch1%3ESimple+example+of+dynamically+adding+rows+with+jQuery+%3C%2Fh1%3E%0A%09%0A%3Cform+action%3D%22'
   62   134        INIT_FCALL                                               'htmlentities'
        135        FETCH_R                      global              ~102    '_SERVER'
        136        FETCH_DIM_R                                      ~103    ~102, 'PHP_SELF'
        137        SEND_VAL                                                 ~103
        138        DO_ICALL                                         $104    
        139        ECHO                                                     $104
        140        ECHO                                                     '%22+method%3D%22POST%22%3E%0A%09%3Cdiv+ID%3D%22itemRows%22%3E%0A%09%0A%09Minimum+Balance%3A+%3Cinput+type%3D%22text%22+name%3D%22Minimum_Balance%22+size%3D%2230%22+%2F%3E+%0A++++Interest+Rate%3A+%3Cinput+type%3D%22text%22+name%3D%22Interest_Rate%22+%2F%3E+%0A++++APY%3A+%3Cinput+type%3D%22text%22+name%3D%22APY%22+%2F%3E+%0A+++++Order%3A+%3Cinput+type%3D%22text%22+name%3D%22sub_order%22+size%3D%222%22%2F%3E+%0A++++%0A++++%0A++++%0A++++%3Cinput+onClick%3D%22addRow%28this.form%29%3B%22+type%3D%22button%22+value%3D%22Add+row%22+%2F%3E+%28This+row+will+not+be+saved+unless+you+click+on+%22Add+row%22+first%29%0A%0A%09'
   77   141      > JMP                                                      ->179
   78   142    >   ECHO                                                     '%09%09%3Cp+ID%3D%22oldRow'
        143        FETCH_DIM_R                                      ~105    !5, 'ID'
        144        ECHO                                                     ~105
        145        ECHO                                                     '%22%3E%0A++++++++%0A++++++++%3Cinput+type%3D%22text%22+name%3D%22dep_rate_cat'
   80   146        FETCH_DIM_R                                      ~106    !5, 'dep_rate_cat'
        147        ECHO                                                     ~106
        148        ECHO                                                     '%22+size%3D%224%22+value%3D%22'
        149        FETCH_DIM_R                                      ~107    !5, 'dep_rate_cat'
        150        ECHO                                                     ~107
   81   151        ECHO                                                     '++++++++Minimum+Balance%3A+%3Cinput+type%3D%22text%22+name%3D%22Min_Balance'
        152        FETCH_DIM_R                                      ~108    !5, 'Min_Balance'
        153        ECHO                                                     ~108
        154        ECHO                                                     '%22+size%3D%224%22+value%3D%22'
        155        FETCH_DIM_R                                      ~109    !5, 'Min_Balance'
        156        ECHO                                                     ~109
        157        ECHO                                                     '%22+%2F%3E%0A+++++++++Interest+Rate%3A+%3Cinput+type%3D%22text%22+name%3D%22Interest_rate'
   82   158        FETCH_DIM_R                                      ~110    !5, 'Interest_Rate'
        159        ECHO                                                     ~110
        160        ECHO                                                     '%22+value%3D%22'
        161        FETCH_DIM_R                                      ~111    !5, 'Interest_Rate'
        162        ECHO                                                     ~111
        163        ECHO                                                     '%22+%2F%3E+%0A++++++++%0A+++++++++APY%3A+%3Cinput+type%3D%22text%22+name%3D%22Apy'
   84   164        FETCH_DIM_R                                      ~112    !5, 'Apy'
        165        ECHO                                                     ~112
        166        ECHO                                                     '%22+value%3D%22'
        167        FETCH_DIM_R                                      ~113    !5, 'Apy'
        168        ECHO                                                     ~113
        169        ECHO                                                     '%22+%2F%3E%0A++++++++++Order%3A+%3Cinput+type%3D%22text%22+name%3D%22sub_order'
   85   170        FETCH_DIM_R                                      ~114    !5, 'sub_order'
        171        ECHO                                                     ~114
        172        ECHO                                                     '%22+value%3D%22'
        173        FETCH_DIM_R                                      ~115    !5, 'sub_order'
        174        ECHO                                                     ~115
        175        ECHO                                                     '%22+%2F%3E%0A+++++++++%3Cinput+type%3D%22checkbox%22+name%3D%22delete_IDs%5B%5D%22+value%3D%22'
   86   176        FETCH_DIM_R                                      ~116    !5, 'ID'
        177        ECHO                                                     ~116
        178        ECHO                                                     '%22%3E+Mark+to+delete%3C%2Fp%3E%0A++++++++%0A%0A%09'
   77   179    >   INIT_FCALL_BY_NAME                                       'mysqli_fetch_array'
        180        SEND_VAR_EX                                              !4
        181        DO_FCALL                                      0  $117    
        182        ASSIGN                                           ~118    !5, $117
        183      > JMPNZ                                                    ~118, ->142
   90   184    >   ECHO                                                     '%09%0A%09%3C%2Fdiv%3E%0A%09%0A%09%3Cp%3E%3Cinput+type%3D%22submit%22+name%3D%22ok%22+value%3D%22Save+Changes%22%3E%3C%2Fp%3E%0A%09%3C%2Fform%3E%0A%3C%2Fdiv%3E%0A%0A%3Cscript+type%3D%22text%2Fjavascript%22%3E%0Avar+rowNum+%3D+0%3B%0Afunction+addRow%28frm%29+%7B%0A%09rowNum+%2B%2B%3B%0A%09var+row+%3D+%27%3Cp+ID%3D%22rowNum%27%2BrowNum%2B%27%22%3EMinimum+Balance+%3A+%3Cinput+type%3D%22text%22+name%3D%22Min_balance%5B%5D%22+size%3D%224%22+value%3D%22%27%2Bfrm.add_Min_Balance.value%2B%27%22%3E+%0A%09Interest+Rate%3A+%3Cinput+type%3D%22text%22+name%3D%22Interest_Rate%5B%5D%22+value%3D%22%27%2Bfrm.add_Interest_Rate.value%2B%27%22%3E+%0A%09APY%3A+%3Cinput+type%3D%22text%22+name%3D%22Apy%5B%5D%22+value%3D%22%27%2Bfrm.add_Apy.value%2B%27%22%3E%0A%09Order%3A+%3Cinput+type%3D%22text%22+name%3D%22sub_order%5B%5D%22+value%3D%22%27%2Bfrm.add_sub_order.value%2B%27%22%3E%0A%09%3Cinput+type%3D%22button%22+value%3D%22Remove%22+onclick%3D%22removeRow%28%27%2BrowNum%2B%27%29%3B%22%3E%3C%2Fp%3E%27%3B%0A%09jQuery%28%27%23itemRows%27%29.append%28row%29%3B%0A%09frm.add_Min_Balance.value+%3D+%27%27%3B%0A%09frm.add_Interest_Rate.value+%3D+%27%27%3B%0A%09frm.add_Apy.value+%3D+%27%27%3B%0A%09frm.add_sub_order.value+%3D+%27%27%3B%0A%7D%0A%0A%0Afunction+removeRow%28rnum%29+%7B%0A%09jQuery%28%27%23rowNum%27%2Brnum%29.remove%28%29%3B%0A%7D%0A%3C%2Fscript%3E%0A%3C%2Fbody%3E%09%0A%3C%2Fhtml%3E'
  119   185      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
202.24 ms | 1416 KiB | 17 Q