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>
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /in/g5Yc3:4 Stack trace: #0 {main} thrown in /in/g5Yc3 on line 4
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
51.98 ms | 401 KiB | 8 Q