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>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0090.00918.27
8.3.50.0120.01021.20
8.3.40.0140.00019.18
8.3.30.0070.00720.29
8.3.20.0080.00020.25
8.3.10.0090.00021.23
8.3.00.0050.00322.46
8.2.180.0160.01017.00
8.2.170.0130.00922.96
8.2.160.0070.00722.26
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0050.00320.79
8.2.110.0040.00819.54
8.2.100.0090.00318.03
8.2.90.0040.00418.16
8.2.80.0040.00417.97
8.2.70.0030.00617.93
8.2.60.0000.00818.22
8.2.50.0000.00818.10
8.2.40.0030.00619.42
8.2.30.0040.00419.39
8.2.20.0000.00817.85
8.2.10.0040.00417.91
8.2.00.0030.00717.87
8.1.280.0060.01225.92
8.1.270.0080.00023.99
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0030.00622.50
8.1.230.0080.00421.15
8.1.220.0040.00417.89
8.1.210.0080.00019.11
8.1.200.0070.00417.34
8.1.190.0040.00417.38
8.1.180.0060.00318.10
8.1.170.0030.00618.77
8.1.160.0000.00818.93
8.1.150.0000.00818.71
8.1.140.0040.00717.59
8.1.130.0000.00717.90
8.1.120.0040.00417.56
8.1.110.0000.00717.43
8.1.100.0000.00817.57
8.1.90.0000.00717.57
8.1.80.0050.00317.57
8.1.70.0030.00317.41
8.1.60.0060.00317.61
8.1.50.0030.00517.67
8.1.40.0080.00017.62
8.1.30.0050.00217.68
8.1.20.0040.00417.82
8.1.10.0000.00917.73
8.1.00.0040.00417.64
8.0.300.0000.00820.15
8.0.290.0030.00616.75
8.0.280.0000.00718.55
8.0.270.0040.00417.36
8.0.260.0060.00016.98
8.0.250.0000.00717.03
8.0.240.0030.00617.21
8.0.230.0000.00717.14
8.0.220.0000.00717.03
8.0.210.0040.00417.07
8.0.200.0070.00017.04
8.0.190.0070.00017.16
8.0.180.0030.00517.11
8.0.170.0070.00017.06
8.0.160.0030.00516.94
8.0.150.0070.00017.00
8.0.140.0030.00917.05
8.0.130.0000.00613.51
8.0.120.0030.00516.98
8.0.110.0000.00717.09
8.0.100.0040.00416.99
8.0.90.0040.00417.14
8.0.80.0090.00617.12
8.0.70.0020.00517.14
8.0.60.0000.00716.97
8.0.50.0040.00417.18
8.0.30.0130.00917.21
8.0.20.0080.01217.40
8.0.10.0000.00817.14
8.0.00.0100.00916.93
7.4.330.0020.00216.83
7.4.320.0030.00316.49
7.4.300.0000.00616.59
7.4.290.0070.00016.59
7.4.280.0000.00716.57
7.4.270.0000.00716.69
7.4.260.0000.00913.28
7.4.250.0040.00416.55
7.4.240.0000.00716.57
7.4.230.0000.00716.75
7.4.220.0120.01816.49
7.4.210.0100.00916.74
7.4.200.0060.00316.55
7.4.190.0000.00716.69
7.4.160.0110.00716.63
7.4.150.0240.00317.40
7.4.140.0100.01017.86
7.4.130.0080.00916.58
7.4.120.0080.00916.56
7.4.110.0150.00316.79
7.4.100.0070.01116.54
7.4.90.0110.00716.60
7.4.80.0060.01219.39
7.4.70.0100.00716.50
7.4.60.0140.00316.75
7.4.50.0030.00616.52
7.4.40.0020.01122.77
7.4.30.0120.00916.54
7.4.10.0060.01315.27
7.4.00.0070.00914.95
7.3.330.0030.00313.43
7.3.320.0000.00513.41
7.3.310.0040.00416.57
7.3.300.0070.00016.61
7.3.290.0160.00616.54
7.3.280.0080.00916.48
7.3.270.0030.01517.40
7.3.260.0030.01618.24
7.3.250.0120.00516.71
7.3.240.0090.00916.66
7.3.230.0080.00816.63
7.3.210.0030.01316.43
7.3.200.0080.00819.39
7.3.190.0040.01716.59
7.3.180.0030.01316.30
7.3.170.0080.00916.57
7.3.160.0080.01116.56
7.3.130.0040.01514.93
7.3.120.0070.01014.92
7.3.110.0050.01315.05
7.3.100.0110.00314.95
7.3.90.0020.01215.03
7.3.80.0050.00915.03
7.3.70.0020.00714.98
7.3.60.0030.01014.87
7.3.50.0060.01014.83
7.3.40.0040.00814.96
7.3.30.0100.00414.87
7.3.20.0100.00616.78
7.3.10.0060.00816.64
7.3.00.0100.00316.78
7.2.330.0070.01216.82
7.2.320.0030.02216.59
7.2.310.0160.00716.80
7.2.300.0130.00316.72
7.2.290.0090.00816.55
7.2.260.0070.01015.07
7.2.250.0080.01115.14
7.2.240.0030.01114.97
7.2.230.0060.01015.21
7.2.220.0040.00915.36
7.2.210.0040.01115.06
7.2.200.0070.00915.20
7.2.190.0050.01315.20
7.2.180.0030.01314.92
7.2.170.0050.01215.17
7.2.160.0100.00714.81
7.2.150.0040.00816.95
7.2.140.0030.01016.90
7.2.130.0040.01417.05
7.2.120.0070.00717.04
7.2.110.0030.01416.98
7.2.100.0060.00617.00
7.2.90.0090.00616.86
7.2.80.0130.00316.92
7.2.70.0000.01417.00
7.2.60.0030.01016.98
7.2.50.0060.00916.79
7.2.40.0030.00616.84
7.2.30.0030.01616.96
7.2.20.0070.01117.05
7.2.10.0070.01016.92
7.2.00.0080.00818.19
7.1.330.0030.00915.78
7.1.320.0080.00615.94
7.1.310.0030.00615.96
7.1.300.0020.01315.70
7.1.290.0050.00515.89
7.1.280.0080.00715.68
7.1.270.0060.00815.71
7.1.260.0080.00615.82
7.1.250.0040.00815.73
7.1.240.0030.01015.68
7.1.230.0090.00315.54
7.1.220.0060.00615.79
7.1.210.0130.00315.77
7.1.200.0080.00715.83
7.1.190.0040.00715.74
7.1.180.0040.00815.72
7.1.170.0070.00715.54
7.1.160.0030.01015.77
7.1.150.0090.00915.84
7.1.140.0110.00015.95
7.1.130.0030.00615.80
7.1.120.0140.00315.86
7.1.110.0000.01215.89
7.1.100.0080.00917.01
7.1.90.0070.00615.80
7.1.80.0060.00315.86
7.1.70.0030.00816.60
7.1.60.0100.00817.53
7.1.50.0020.01516.44
7.1.40.0070.00715.54
7.1.30.0030.01115.80
7.1.20.0100.00615.57
7.1.10.0130.00015.72
7.1.00.0050.02519.05
7.0.330.0040.00815.23
7.0.320.0040.01115.51
7.0.310.0000.01215.24
7.0.300.0080.00515.39
7.0.290.0030.00615.37
7.0.280.0040.01115.50
7.0.270.0050.00315.41
7.0.260.0030.01515.38
7.0.250.0070.00715.67
7.0.240.0080.00615.30
7.0.230.0000.01315.45
7.0.220.0000.01215.50
7.0.210.0100.00715.17
7.0.200.0080.00916.09
7.0.190.0000.01315.27
7.0.180.0000.01415.49
7.0.170.0050.00515.51
7.0.160.0060.00315.44
7.0.150.0100.00015.42
7.0.140.0050.04418.60
7.0.130.0030.01015.62
7.0.120.0030.01015.34
7.0.110.0060.00615.45
7.0.100.0100.01817.79
7.0.90.0060.04117.73
7.0.80.0050.04417.78
7.0.70.0080.04117.83
7.0.60.0080.03017.79
7.0.50.0100.03917.91
7.0.40.0130.04216.70
7.0.30.0060.03216.66
7.0.20.0050.04616.79
7.0.10.0050.04516.78
7.0.00.0100.03916.72
5.6.400.0030.01014.52
5.6.390.0030.00714.62
5.6.380.0060.00914.42
5.6.370.0030.01214.70
5.6.360.0070.00714.54
5.6.350.0030.01414.13
5.6.340.0000.01714.66
5.6.330.0030.00714.48
5.6.320.0110.00714.06
5.6.310.0090.00614.65
5.6.300.0000.01914.28
5.6.290.0060.01214.28
5.6.280.0070.03917.95
5.6.270.0000.01814.75
5.6.260.0030.01014.36
5.6.250.0040.02317.68
5.6.240.0050.02617.58
5.6.230.0080.03417.35
5.6.220.0140.03717.57
5.6.210.0080.03317.51
5.6.200.0070.04317.83
5.6.190.0070.04817.88
5.6.180.0070.04517.79
5.6.170.0100.04017.87
5.6.160.0080.03517.60
5.6.150.0080.04117.82
5.6.140.0050.05017.71
5.6.130.0170.04017.73
5.6.120.0100.04517.73
5.6.110.0050.04717.71
5.6.100.0050.04517.71
5.6.90.0080.04917.76
5.6.80.0050.04117.57
5.6.70.0100.04217.53
5.6.60.0100.04117.34
5.6.50.0080.04117.40
5.6.40.0050.04417.38
5.6.30.0070.04017.41
5.6.20.0070.04317.36
5.6.10.0020.04617.48
5.6.00.0030.03117.37
5.5.380.0070.04217.50
5.5.370.0080.02717.39
5.5.360.0120.03817.48
5.5.350.0030.04617.27
5.5.340.0090.04217.58
5.5.330.0050.04017.70
5.5.320.0120.04217.58
5.5.310.0080.04517.76
5.5.300.0050.04517.67
5.5.290.0060.03317.43
5.5.280.0050.02917.76
5.5.270.0070.04017.38
5.5.260.0110.03817.65
5.5.250.0060.03817.58
5.5.240.0050.04417.33
5.5.230.0050.04517.07
5.5.220.0050.04317.33
5.5.210.0050.04617.25
5.5.200.0080.03817.27
5.5.190.0070.02717.26
5.5.180.0020.02917.36
5.5.170.0000.00914.32
5.5.160.0070.04417.13
5.5.150.0090.03717.19
5.5.140.0060.04317.11
5.5.130.0070.04017.08
5.5.120.0050.04317.25
5.5.110.0070.03017.10
5.5.100.0080.04417.34
5.5.90.0120.03517.24
5.5.80.0090.04017.27
5.5.70.0120.03817.04
5.5.60.0130.02017.06
5.5.50.0040.04617.11
5.5.40.0160.03317.10
5.5.30.0080.03817.28
5.5.20.0100.04017.06
5.5.10.0070.04017.26
5.5.00.0040.03917.07
5.4.450.0100.04115.27
5.4.440.0000.04815.13
5.4.430.0050.04015.36
5.4.420.0110.04015.32
5.4.410.0050.04115.24
5.4.400.0050.04214.99
5.4.390.0070.02715.00
5.4.380.0070.02615.02
5.4.370.0020.03215.22
5.4.360.0120.03215.03
5.4.350.0060.04015.13
5.4.340.0050.04015.05
5.4.330.0030.00710.86
5.4.320.0020.04414.97
5.4.310.0030.04315.08
5.4.300.0070.04514.96
5.4.290.0050.02514.93
5.4.280.0100.02815.10
5.4.270.0070.04015.14
5.4.260.0050.04515.12
5.4.250.0030.04515.09
5.4.240.0080.03715.00
5.4.230.0050.03915.11
5.4.220.0100.03515.03
5.4.210.0060.03814.99
5.4.200.0060.04315.03
5.4.190.0050.04015.08
5.4.180.0030.03015.22
5.4.170.0060.03815.03
5.4.160.0070.03714.72
5.4.150.0070.03914.93
5.4.140.0070.03713.63
5.4.130.0090.03613.69
5.4.120.0070.04213.51
5.4.110.0050.04113.79
5.4.100.0050.02913.74
5.4.90.0060.04113.71
5.4.80.0060.02113.53
5.4.70.0080.03813.53
5.4.60.0060.04013.67
5.4.50.0050.03713.59
5.4.40.0040.04213.74
5.4.30.0050.03513.59
5.4.20.0050.03813.55
5.4.10.0060.03813.63
5.4.00.0070.03713.40
5.3.290.0100.03812.65
5.3.280.0050.03512.48
5.3.270.0070.04112.59
5.3.260.0050.04512.48
5.3.250.0070.03812.49
5.3.240.0090.03712.57
5.3.230.0080.04012.50
5.3.220.0090.04012.45
5.3.210.0030.02612.48
5.3.200.0080.04012.53
5.3.190.0010.02912.56
5.3.180.0030.04212.59
5.3.170.0070.02412.58
5.3.160.0030.02612.48
5.3.150.0050.04212.51
5.3.140.0080.03612.52
5.3.130.0070.03612.48
5.3.120.0070.03912.49
5.3.110.0050.04212.47
5.3.100.0080.03712.24
5.3.90.0100.02812.18
5.3.80.0100.02112.25
5.3.70.0070.04212.16
5.3.60.0020.02712.23
5.3.50.0050.02512.17
5.3.40.0030.04012.08
5.3.30.0020.04112.22
5.3.20.0030.03711.95
5.3.10.0050.03712.04
5.3.00.0030.03911.97
5.2.170.0030.06711.00
5.2.160.0070.06011.25
5.2.150.0030.06710.98
5.2.140.0030.05311.00
5.2.130.0070.05711.07
5.2.120.0070.06011.08
5.2.110.0100.06311.10
5.2.100.0030.06310.98
5.2.90.0170.05011.20
5.2.80.0070.06310.99
5.2.70.0000.06711.20
5.2.60.0070.05711.15
5.2.50.0030.05011.00
5.2.40.0030.07010.89
5.2.30.0030.04310.86
5.2.20.0030.05710.95
5.2.10.0000.06010.96
5.2.00.0030.06310.71
5.1.60.0070.04310.13
5.1.50.0030.05710.09
5.1.40.0030.0579.86
5.1.30.0100.02710.44
5.1.20.0130.05010.53
5.1.10.0000.0609.95
5.1.00.0070.05310.20
5.0.50.0130.0378.62
5.0.40.0000.0308.57
5.0.30.0000.0678.37
5.0.20.0000.0478.28
5.0.10.0000.0538.31
5.0.00.0000.0708.23
4.4.90.0000.0377.64
4.4.80.0030.0337.64
4.4.70.0030.0377.64
4.4.60.0070.0277.64
4.4.50.0030.0277.64
4.4.40.0030.0537.64
4.4.30.0000.0407.64
4.4.20.0000.0337.64
4.4.10.0070.0307.64
4.4.00.0070.0407.64
4.3.110.0000.0407.64
4.3.100.0030.0177.64
4.3.90.0030.0207.64
4.3.80.0000.0537.64
4.3.70.0030.0337.64
4.3.60.0070.0307.64
4.3.50.0030.0307.64
4.3.40.0000.0407.64
4.3.30.0000.0377.64
4.3.20.0070.0337.64
4.3.10.0030.0377.64
4.3.00.0000.0377.64

preferences:
38.88 ms | 401 KiB | 5 Q