<?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>
Warning: include(): open_basedir restriction in effect. File(connect.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/aXTKX on line 5
Warning: include(connect.php): Failed to open stream: Operation not permitted in /in/aXTKX on line 5
Warning: include(): Failed opening 'connect.php' for inclusion (include_path='.:') in /in/aXTKX on line 5
Warning: Undefined array key "CAT" in /in/aXTKX on line 7
Warning: Undefined variable $link in /in/aXTKX on line 48
Fatal error: Uncaught Error: Call to a member function query() on null in /in/aXTKX:48
Stack trace:
#0 {main}
thrown in /in/aXTKX on line 48
Process exited with code 255.
Output for 8.0.13
Warning: include(connect.php): Failed to open stream: No such file or directory in /in/aXTKX on line 5
Warning: include(): Failed opening 'connect.php' for inclusion (include_path='.:') in /in/aXTKX on line 5
Warning: Undefined array key "CAT" in /in/aXTKX on line 7
Warning: Undefined variable $link in /in/aXTKX on line 48
Fatal error: Uncaught Error: Call to a member function query() on null in /in/aXTKX:48
Stack trace:
#0 {main}
thrown in /in/aXTKX on line 48
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.26, 7.4.33
Warning: include(connect.php): failed to open stream: No such file or directory in /in/aXTKX on line 5
Warning: include(): Failed opening 'connect.php' for inclusion (include_path='.:') in /in/aXTKX on line 5
Notice: Undefined index: CAT in /in/aXTKX on line 7
Notice: Undefined variable: link in /in/aXTKX on line 48
Fatal error: Uncaught Error: Call to a member function query() on null in /in/aXTKX:48
Stack trace:
#0 {main}
thrown in /in/aXTKX on line 48
Process exited with code 255.
Warning: include(): open_basedir restriction in effect. File(connect.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/aXTKX on line 5
Warning: include(connect.php): failed to open stream: Operation not permitted in /in/aXTKX on line 5
Warning: include(): Failed opening 'connect.php' for inclusion (include_path='.:') in /in/aXTKX on line 5
Notice: Undefined index: CAT in /in/aXTKX on line 7
Notice: Undefined variable: link in /in/aXTKX on line 48
Fatal error: Uncaught Error: Call to a member function query() on null in /in/aXTKX:48
Stack trace:
#0 {main}
thrown in /in/aXTKX on line 48
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Warning: include(): open_basedir restriction in effect. File(connect.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/aXTKX on line 5
Warning: include(connect.php): failed to open stream: Operation not permitted in /in/aXTKX on line 5
Warning: include(): Failed opening 'connect.php' for inclusion (include_path='.:') in /in/aXTKX on line 5
Notice: Undefined index: CAT in /in/aXTKX on line 7
Notice: Undefined variable: link in /in/aXTKX on line 48
Fatal error: Uncaught Error: Call to a member function query() on unknown in /in/aXTKX:48
Stack trace:
#0 {main}
thrown in /in/aXTKX on line 48
Process exited with code 255.
Output for 5.6.0 - 5.6.40
Warning: include(): open_basedir restriction in effect. File(connect.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/aXTKX on line 5
Warning: include(connect.php): failed to open stream: Operation not permitted in /in/aXTKX on line 5
Warning: include(): Failed opening 'connect.php' for inclusion (include_path='.:') in /in/aXTKX on line 5
Notice: Undefined index: CAT in /in/aXTKX on line 7
Notice: Undefined variable: link in /in/aXTKX on line 48
Fatal error: Call to a member function query() on null in /in/aXTKX on line 48
Process exited with code 255.
Output for 5.5.0 - 5.5.38
Warning: include(): open_basedir restriction in effect. File(connect.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/aXTKX on line 5
Warning: include(connect.php): failed to open stream: Operation not permitted in /in/aXTKX on line 5
Warning: include(): Failed opening 'connect.php' for inclusion (include_path='.:') in /in/aXTKX on line 5
Notice: Undefined index: CAT in /in/aXTKX on line 7
Notice: Undefined variable: link in /in/aXTKX on line 48
Fatal error: Call to a member function query() on a non-object in /in/aXTKX on line 48
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45
Warning: include(connect.php): failed to open stream: No such file or directory in /in/aXTKX on line 5
Warning: include(): Failed opening 'connect.php' for inclusion (include_path='.:') in /in/aXTKX on line 5
Notice: Undefined index: CAT in /in/aXTKX on line 7
Notice: Undefined variable: link in /in/aXTKX on line 48
Fatal error: Call to a member function query() on a non-object in /in/aXTKX on line 48
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Warning: include(connect.php): failed to open stream: No such file or directory in /in/aXTKX on line 5
Warning: include(): Failed opening 'connect.php' for inclusion (include_path='.:') in /in/aXTKX on line 5
Notice: Undefined index: CAT in /in/aXTKX on line 7
Notice: Undefined variable: link in /in/aXTKX on line 48
Fatal error: Call to a member function query() on a non-object in /in/aXTKX on line 48
Process exited with code 255.
Output for 5.0.4 - 5.0.5
Warning: main(connect.php): failed to open stream: No such file or directory in /in/aXTKX on line 5
Warning: main(): Failed opening 'connect.php' for inclusion (include_path='.:') in /in/aXTKX on line 5
Notice: Undefined index: CAT in /in/aXTKX on line 7
Notice: Undefined variable: link in /in/aXTKX on line 48
Fatal error: Call to a member function query() on a non-object in /in/aXTKX on line 48
Process exited with code 255.
Output for 5.0.0 - 5.0.3
Warning: main(connect.php): failed to open stream: No such file or directory in /in/aXTKX on line 5
Warning: main(): Failed opening 'connect.php' for inclusion (include_path='.:') in /in/aXTKX on line 5
Notice: Undefined index: CAT in /in/aXTKX on line 7
Notice: Undefined variable: link in /in/aXTKX on line 48
Fatal error: Call to a member function query() on a non-object in /in/aXTKX on line 48
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Warning: main(connect.php): failed to open stream: No such file or directory in /in/aXTKX on line 5
Warning: main(): Failed opening 'connect.php' for inclusion (include_path='.:') in /in/aXTKX on line 5
Notice: Undefined index: CAT in /in/aXTKX on line 7
Fatal error: Call to a member function on a non-object in /in/aXTKX on line 48
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: main(connect.php) [http://www.php.net/function.main]: failed to create stream: No such file or directory in /in/aXTKX on line 5
Warning: main() [http://www.php.net/function.main]: Failed opening 'connect.php' for inclusion (include_path='.:') in /in/aXTKX on line 5
Notice: Undefined index: CAT in /in/aXTKX on line 7
Fatal error: Call to a member function on a non-object in /in/aXTKX on line 48