$_get keep getting the same value where they are supposed to get different values.

By James David Deann

i’m trying to build update function with javascript and php,

what i’m trying to to is
when i click on sections that i want to edit, it opens editing form with the data.

and when i finish editing, it gives the content, and the column name to php file.

like this code, when i click either program, or javascript or english,

<div id="program" class="BackColor" onclick="field('program')"> PRogram</div>
<div id="js" class="BackColor" onclick="field('js')"> Javascript</div>
<div id="english" class="BackColor" onclick="field('english')"> English</div>
function field(str){
  if(str == "program"){
    document.getElementById("field").innerHTML = "program";
    <?php
    $data = $program;
    $name = "program";
    ?>
  }else if(str == "js"){
    document.getElementById("field").innerHTML = "Javascript";
     <?php
    $data = $js;
    $name = "javascript";
    ?>
  }
  else if(str == "english"){
    document.getElementById("field").innerHTML = "English";
     <?php
    $data = $english;
    $name = "english";
    ?>
  }
}

it opens the editing form with the data. and put the name of the column into php variable $name so i can use in PHP when i update something depending on what i edited.

<div class="test1">
<form method="post" name="Okay" action="practice_check.php?name=<?=$name?>">
<table>
  <tr>
    <th> <div id="field"></div> <br>
      <textarea name="Content" id="Content" cols="30" rows="10"><?php  echo  $data ?></textarea>
    </th>
  </tr>
  </table>
   <input class="okay" type="submit" value=" Okay"></input>
 </form>
 <form method="post" name="Okay" action="practice.php">
   <input class="okay" type="submit" value="back to the site"></input>
 </form>
</div>

but my problem is when i get the value from form tag like this in PHP
( action=”practice_check.php?name=” )

<?php
$content = $_POST["Content"];
$name = $_GET["name"];
print $name;
print $content;
?>

the name variable that i get in PHP is always the last value in the function, which in my case “english”, even though i edited program or javascript section.
when i click on program or javascript, it changes ” field ID ” section and get the data depending on the i choose, which i think the function works without problems. but i don’t know why i keep having the same value in PHP.

get i get some help from you?

Source: Stack Overflow

    

Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273