单击行将html表jquery中的值提交到mysql查询

时间:2016-05-10 02:10:46

标签: javascript php jquery html mysql

我试图从表中获取值并使用jQuery在mysql查询中插入该值只是为了点击行。这段代码从html表中提交并获取值,但是它无法定义mysql查询所需的php值$ club。所以我需要点击在html行值的mysql查询中提交该值。 这个jquery将值放在我的所有选择/ dropmenus中:

Array ( [position] => Reds [league] => Reds [limit] => Reds [club] => Reds )

需要:

Array ( [position] =>  [league] =>  [limit] =>  [club] => Reds )

的jQuery

<script type="text/javascript">
$("table").on('click','tr',function(e){
    e.preventDefault();
    var id = $(this).attr('value');
    alert(id);
var $form = $('#leagueForm');
// set the input value
$form.find('input').val(id);

$form.submit();
});
</script>

HTML

<form method="post" id="leagueForm" action="index.php"><input name="club" type="hidden"/></form>

HTML表格

<table>
<thead>
<tr>
<th class="nosort" data-sortcolumn="0" data-sortkey="0-0">Team</th>
<th class="nosort" data-sortcolumn="1" data-sortkey="1-0">Name</th>
<th class="nosort" data-sortcolumn="2" data-sortkey="2-0">Games</th>
<th class="nosort" data-sortcolumn="3" data-sortkey="3-0">Came</th>
<th class="nosort" data-sortcolumn="4" data-sortkey="4-0">Perc</th>
<th data-defaultsort="asc" class="down sorted" data-sortcolumn="5" data-sortkey="5-0">Odds<span class="sign arrow"></span></th>
<th class="nosort" data-sortcolumn="6" data-sortkey="6-0"> </th>
</tr>
</thead>
<tr value="Reds"><td>Reds</td>
<td>Reds</td><td>18</td><td>11</td><td>61.1%</td><td class="sorted">1.64</td><td></td></tr>
</table>

PHP提交按钮(之前)

<td><button name='club' type='submit' class='btn btn-xs btn-default' value=".$row['home'].">". Click . "</button></td>

的MySQL

$sql = "SELECT * FROM results  WHERE $position='$club' order by datum desc";

0 个答案:

没有答案