Wednesday, 15 April 2015

mysql - Only getting the last row from a table using POST with PHP -


i ?? 'Am new to PHP and I have a problem getting data from the post. I have a SQL query that selects from Table 3 column, which I resonate in the table form. Note that only 3 columns should have input type. Although the table looks fine (all values ​​from mySQL), when I print the third column variable from $ _ POST , only the last value is printed. Here is the code:

  $ result = mysql_query ("` id`, `component`,` `select percent` from waste_percentage`) or die (mysql_error ()); $ Line = mysql_fetch_array ($ result); Echo "& lt; table border = '1' cellspacing = '0'>  $ field1 ;"; Echo "& lt; td> $ field2 ;"; Echo "& lt; td & gt;" . "& Lt; input type = \" text \ "name = \" percent \ "value =". $ Field 3 "& lt; / td & gt;"; Echo "& lt; td & gt;" . "& Lt; input type = \" hidden \ "name = \" hidden \ "value =". $ Line ['id'] "& lt; / td & gt;"; Echo "& lt; / tr & gt;"; }} Echo "& lt; / table & gt;"; Echo "& lt; input name = \" submitpercent \ "type = \" \ "value = \" i £ i ?? νÎÏ ?? ÎμιΠ± \ submit "/>"; Echo ""; // If I try to produce (isset ($ _ post ['Submitpercent'])) {$ USER_PERCENTAGE [] = $ _POST ['percent']; Print_r ($ user_percentage); }   

Output is: 'Array ([0] => 13.60)' Thanks for any help! thank you in advanced.

You can change your & lt; Input & gt; tag, like this:

  echo "& lt; td & gt; . "& Lt; input type = \" text \ "name = \" percent \ "value = \" ". $ Field3." \ "& Gt; & lt; / td & gt;"; Echo "& lt; td & gt;" . "& Lt; input type = \" hidden \ "name = \" hidden \ "value = \" ". $ Line ['id']." \ "& Gt; & lt; / td & gt;";    

No comments:

Post a Comment