Note that there are some explanatory texts on larger screens.

plurals
  1. POdynamic row values wrongly updated into mysql php
    text
    copied!<p>Here i'm trying to edit &amp; update my dynamic row values using php. This is my edit.php page coding. it fetch the dynamic row datas from mysql perfectly..</p> <pre><code>$uid = (int)$_GET['id']; $tariff_query = mysql_query("SELECT * FROM ebvouchertariffs WHERE VoucherID_Fk = $uid"); if(mysql_num_rows($tariff_query)&gt;=1) { echo "&lt;table&gt; &lt;tr&gt; &lt;td&gt;SL.NO&lt;/td&gt; &lt;td&gt;DATE&lt;/td&gt; &lt;td&gt;PARTICULARS&lt;/td&gt; &lt;td&gt;NO OF NIGHTS&lt;/td&gt; &lt;td&gt;RATE&lt;/td&gt; &lt;td&gt;PRICE&lt;/td&gt; &lt;td&gt;TAX %&lt;/td&gt; &lt;/tr&gt;"; while($t_row = mysql_fetch_array($tariff_query)) { echo "&lt;tr&gt; &lt;td&gt;&lt;input type=text name=slno[] value= ". $t_row['TariffSlNo'] ."&gt;&lt;/td&gt; &lt;td&gt;&lt;input type=text value=". $t_row['TariffDate'] ." name=date[] id=SelectedDate onClick=GetDate(this); readonly=readonly/&gt;&lt;/td&gt; &lt;td&gt;&lt;input type=text name=particulars[] placeholder=\"Description\" value=". $t_row['TariffParticulars'] ."&gt;&lt;/td&gt; &lt;td&gt;"; echo "&lt;select name=noofnights[] value= &gt;"; echo "&lt;option&gt;" . $t_row['NoOfNights'] . "&lt;/option&gt;"; echo "&lt;option&gt;&lt;/option&gt;"; echo "&lt;option value=1&gt;1&lt;/option&gt; &lt;option value=2&gt;2&lt;/option&gt; &lt;!-- cutted --&gt; &lt;option value=20&gt;20&lt;/option&gt;"; echo "&lt;/select&gt;"; echo " &lt;input type=text onblur=\"this.value=addzeros(this.value)\" onKeyUp=\"return valtxt(this)\" name=rate[] value=". $t_row['TariffRate'] ."&gt; &lt;input type=text name=price[] value=". $t_row['TariffPrice'] ." readonly=readonly&gt; &lt;input type=text name=tax[] onblur=\"this.value=addzeros(this.value)\" onKeyUp=\"return valtxt(this)\" value=". $t_row['TariffTax'] ." &gt; &lt;input type=hidden name=taxtotal[] readonly=readonly value= &gt;&lt;/td&gt; &lt;/tr&gt;"; } } </code></pre> <p>This is my update.php page coding. it updates the datas wrongly. </p> <p><strong>Before Update :</strong></p> <p><img src="https://i.stack.imgur.com/nJtYc.png" alt="enter image description here"></p> <p><strong>After Update :</strong></p> <p><img src="https://i.stack.imgur.com/vYj2n.png" alt="enter image description here"></p> <p>i edited all rows and columns and when i updated the voucher it always updates the last row values in all rows. you can see in that image. But i'm using edit and update option for single text field. it workings fine. Dynamic row values wrongly updated into database. for generate dynamic rows i'm using javascript... how to solve this problem?</p> <pre><code>include("config.php"); if(isset($_POST['submit_val'])) { $uid = (int)$_POST["edited"]; foreach( $_POST['slno'] as $key=&gt;$slno ) { $e_date = $_POST['date'][$key]; $e_particulars = $_POST['particulars'][$key]; $e_noofnights = $_POST['noofnights'][$key]; $e_rate = $_POST['rate'][$key]; $e_price = $_POST['price'][$key]; $e_tax = $_POST['tax'][$key]; $e_nettotal = $_POST['nettotal']; $e_totalamount = $_POST['totalamount']; $e_finaltotal = $_POST['finaltotal']; $e_slno = mysql_real_escape_string($slno); $e_date = mysql_real_escape_string($e_date); $e_particualrs = mysql_real_escape_string($e_particulars); $e_noofnights = mysql_real_escape_string($e_noofnights); $e_rate = mysql_real_escape_string($e_rate); $e_price = mysql_real_escape_string($e_price); $e_tax = mysql_real_escape_string($e_tax); $e_nettotal = mysql_real_escape_string($e_nettotal); $e_totalamount = mysql_real_escape_string($e_totalamount); $e_finaltotal = mysql_real_escape_string($e_finaltotal); $e_tariff = "UPDATE ebvouchertariffs SET TariffSlNo = '$e_slno', TariffDate = '$e_date', TariffParticulars = '$e_particulars', NoOfNights = '$e_noofnights', TariffRate = '$e_rate', TariffPrice = '$e_price', TariffTax = '$e_tax', TariffNetTotal = '$e_nettotal', TariffAddTotal = '$e_totalamount', TariffFinalTotal = '$e_finaltotal', ModifiedOn = NOW() WHERE VoucherID_Fk = '$uid'"; } mysql_query($e_tariff)or die(mysql_error()); mysql_close($link); } </code></pre> <p>I posted another question here <a href="https://stackoverflow.com/questions/20794722/mysql-wrongly-update-the-dynamic-row-records">Here is the link for another question</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload