Note that there are some explanatory texts on larger screens.

plurals
  1. POEdit multiple MySQL rows using PHP where primary key is same for all rows
    primarykey
    data
    text
    <p>I am referencing the URL <a href="http://www.shotdev.com/php/php-mysql/php-mysql-edit-update-data/" rel="nofollow">http://www.shotdev.com/php/php-mysql/php-mysql-edit-update-data/</a> to edit rows from a MySQL table. The page displays fine with the edit button besides each row. However, upon clicking any of the edit button on any of the rows, it shows input/edit for the last row. </p> <p>The reason why this would be occurring maybe because we have primary key(auto-incremented) as "abc-2010-2011-1" (abc-2010-2011-2, abc-2010-2011-3) &amp; not id. Secondly, there are multiple rows referencing the same primary key such as abc-2010-2011-1. So when we try editing the first row from the table, it tries editing/displays input for the last row of the array. </p> <pre><code>&lt;? $objConnect = mysql_connect("localhost","app","abc123") or die(mysql_error()); $objDB = mysql_select_db("quotation"); $serial=$objResult['serial_no']; $parti=$objResult['particulars']; $qnt=$objResult['quantity']; $untp=$objResult['unit_price']; $i=1; foreach(serial_no as $val) { $strSQL = "SELECT * FROM table1 WHERE complete_qtn_no = '".$_GET["CusID[]"]. "' and serial_no=$val[$i] ; "; $objQuery = mysql_query($strSQL); $objResult = mysql_fetch_array($objQuery); $i++; } if(!$objResult) { echo "Quotation number not found =".$_GET["CusID"]; } else { ?&gt; </code></pre> <p>Below is entries from table1,</p> <pre><code>+----+------------------------+------------+------------------------------------+-----------+-------------+----------+------------+---------+----------+-----------+-------------------+------------+------------+---------+---------+-----------+ | id | to_addr | app_date | subject_quote | serial_no | particulars | quantity | unit_price | tamount | delivery | payment | complete_qtn_no | tax_value1 | tax_value2 | tax1 | tax2 | net_total | +----+------------------------+------------+------------------------------------+-----------+-------------+----------+------------+---------+----------+-----------+-------------------+------------+------------+---------+---------+-----------+ | 79 | test | 01/06/11 | Quotation as per your requirements | 2 | TESTING2 | 78 | 98.56 | 7687.68 | 2 Days | Immediate | ABC-QTN-2010-11-20 | 16 | 0 | 1230.03 | 0 | 8917.71 | | 78 | test1 | 01/06/11 | Quotation as per your requirements | 1 | TESTING | 16 | 78.89 | 1262.24 | 2 Days | Immediate | ABC-QTN-2010-11-20 | 3 | 16 | 37.8672 | 201.958 | 1502.07 | | 77 | test3| | Quotation as per your requirements | 3 | Cable | 68 | 89.76 | 6103.68 | 2 Days | Immediate | ABC-QTN-2010-11-19 | 3 | 12.5 | 183.11 | 762.96 | 7049.75 | | 76 | test4| | Quotation as per your requirements | 2 | Motor | 16 | 78.8 | 1260.8 | 2 Days | Immediate | ABC-QTN-2010-11-19 | 16 | 0 | 201.728 | 0 | 1462.53 | | 75 | test5 | | Quotation as per your requirements | 1 | Pipe | 10 | 15 | 150 | 2 Days | Immediate | abc-QTN-2010-11-19 | 3 | 16 | 4.5 | 24 | 178.5 | +----+------------------------+------------+------------------------------------+-----------+-------------+----------+------------+---------+----------+-----------+-------------------+------------+------------+---------+---------+-----------+ </code></pre> <p>Thank you for your help in advance. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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