Updating the form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • onlymars
    New Member
    • Mar 2008
    • 13

    Updating the form

    hi guys, i am stucked in a problem, my php generated form isn't getting updated. the code of show.php is below;
    [code=php]
    while($curr=mys ql_fetch_array( $result2))
    {
    $a=$curr['curr_name'];
    $b=$curr['curr_amount'];

    echo "<tr><td class='style4' width='100'>";
    echo "<input name='amountold[]' type='hidden' value='" . $b . "'>";

    echo strtoupper($a);
    echo "<td class='style4' width='100'>";
    echo "<input name='amount[]' value='" . $b . "'>";
    }
    [/code]

    the update page code
    [code=php]
    $amount=$_POST['amount'];
    $amountold=$_PO ST['amountold'];

    $i=0;
    while (list ($key1,$val1) = @each ($amountold))
    {
    $old1[$i]="$val1";
    $i++;
    }

    $b=0;
    while (list ($key2,$val2) = @each ($amount))
    {

    $m=(float)$val2 ;
    $n=(float)$old1[$b];

    mysql_query("UP DATE currency SET curr_amount='$m ' WHERE curr_amount='$n ' ");
    $b++;
    }
    [/code]

    well i receive the values correctly in the array and i convert every single value to float but its not getting updated, i am sure its a problem with the variable type of float. by the way the field amount in my database mysql is in float. i dont know wtas going on, plz help me out.
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    First thing to debug is the result of the UPDATE command, so change your statement to[php]mysql_query("UP DATE currency SET curr_amount='$m ' WHERE curr_amount='$n ' ")
    or die("Update failed: ".mysql_error() );[/php]and see what error this throws out.

    Ronald

    Comment

    • onlymars
      New Member
      • Mar 2008
      • 13

      #3
      well i putted the mysql query in an if statement to check if its really working and it is working but cant load the values in the table.

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        Theh your WHERE clause specifies the wro9ng value. Wherever does the variable $n come from, as in[php]WHERE curr_amount='$n ' ")[/php]It is nowhere else to be seen in your code of that script!

        Ronald

        Comment

        Working...