(After sales) I wish to dynamically add and save the additional values of contributed sum in to the mysql table named Donation campaigns. (Frontend) User selects a quantity (SELECTed from db Campaigns) and Place it into certain area of db User Donations. I am really do not understand what related to the next. Please assist me to for any thanks donation to resolve the issue.


 <div>Choose your sum</div>
  <div id="camp_sum_list">
  <?php $camp_sum_num = attribute_escape($post["camp_sum_num"]);
  $camp_sums = array();
  for ($i = 0; $i < $camp_sum_num; $i++) {
    $sum_value = attribute_escape($post["camp_sum_" . $i]);
    if ($camp_sum_value != null && $sum_value != "") {
        $camp_sums[] = $camp_sum_value;
  } ?>
  <?php $id = 0; ?>
  <?php foreach ($camp_sums as $camp_sum) : ?>
  <div id="camp_sum_<?php echo $id; ?>">
   <input type="text" class="sum_option" name="camp_sum_<?php echo $id; ?>" value="<?php echo $sum; ?>" /><a href="#" onClick="return removeFormTextField('camp_sum_list', 'camp_sum_<?php echo $id; ?>')">Remove</a>
  <?php $id++; ?>
  <?php endforeach; ?>
  <input type="hidden" name="camp_sum_num" value="<?php echo count($camp_sums);?>" id="camp_sum_num"/>
   <div id="add-new-sum"><a class="button" href="#" onclick="return addFormTextField('camp_sum_num', 'camp_sum_list', 'camp_sum_', 'sum_option');">Add new</a></div>


        $output .='<p class="cont_sum"><label for="cont_sum">'.__('Choose your sum').'</label><select name="cont_sum">';
        $output .='<option value="'.__($CampRow->camp_sum_num).'">'.__($CampRow->camp_sum_num).'</option>';
        $output .='</select></p>';

I do not really understand your present code, there's no database-connection or perhaps a SQL-query inside... and so i designed a simple form to submit something to some database...

Submit a add up to an offer, put this in file1.php

$db = mysqli_connect('localhost', 'username', 'password', 'database-name');
    $sql_insert = "INSERT INTO UserDonations (userID, campaignID, amount) VALUES ('".$_SESSION['userID']."', '".$_POST['campaign']."', '".$_POST['amount']."');";
    $result_insert = mysqli_query($db, $sql_insert);
    echo "
    <form method=\"POST\">
        <select name=\"campaign\">";

    $sql_campaigns = "SELECT * FROM Campaigns";
    $result_campaigns = mysqli_query($db, $sql_campaigns);
    while($row_campaigns = mysqli_fetch_object($result_campaigns))
        echo "
            <option value=\"".$row_campaigns->campaignID."\">".$row_campaigns->name;

    echo "
        <input type=\"text\" name=\"amount\">
        <input type=\"submit\" name=\"submit\" value=\"Add funds\">

show a counter around the campaign site.. put this in file2.php (but ultimately you need to put this inside your campaign-page)

$db = mysqli_connect('localhost', 'username', 'password', 'database-name');
$campaignID = "12";
$sql_current = "SELECT SUM(amount) total_amount FROM UserDonations WHERE campaignID = '".$campaignID."';";
$result_current = mysqli_query($db, $sql_current);
$row_current = mysqli_fetch_object($result_current);
echo "