2016-07-31 6 views
1

ボタンの値を$_POST["class_name"]に渡そうとしていますので、selectclass.phpで使用できます。私は、テーブルのボタンをクリックして$ _POST =ボタンの値を、または可能であればボタンの隣にあるclass_idを持つことができるようにします。どんな助けでも本当に感謝しています。PHP、html:投稿するボタンの値を渡す方法

<tbody> 
      <form action="selectclass.php" method="post"> 
      <?php foreach ($classes as $class): ?> 

       <tr> 

        <th><button type="text" name = "class_id"><?=$class["class_name"]?></button></th> 
        <th><?=$class["class_id"] ?></th> 

       </tr> 

     <?php endforeach ?> 
     </form> 
     </tbody> 

答えて

2

あなたはそれが価値を持つようにしたい場合は、value属性を使用して、それを1つずつ与える:

<button type="text" name="class_id" value="some_value"> 

ええ、おかげで、私はおそらくについてもう少しのために考えている可能性が<button> on MDN

+1

を参照してください。これです。 – Marcel

関連する問題