在while循环中提交按钮

时间:2016-03-29 23:40:41

标签: php html while-loop

对于有经验的用户来说,我的问题可能很容易,但我对它很感兴趣。所以,这就是问题所在。我在while循环中提交按钮,他们画画,但他们没有对点击作出反应。这是我的一段代码。

`<?php
$zap_cmember = count_query("SELECT * FROM `users` WHERE `clan` = '".$member['id']."' AND clan_stat != 'Призывник'");
while ($cmember = mysql_fetch_array($zap_cmember))
{
$zap_gold = mysql_result(mysql_query("SELECT SUM(gold) FROM klog WHERE name = '".$cmember['name']."'"), 0);
$zap_online = mysql_num_rows(count_query("SELECT * FROM `online` WHERE `id_session`='".$cmember['id_user']."'"));
if ($zap_online > 0)
{
    $img_on = "<td align='center' valign='middle' ><img src='images/ico_online.png' alt='онлайн' class='png' ></td>";
}
else
{
    $img_on = "<td align='center' valign='middle' ><img src='images/ico_offline.png' alt='оффлайн' class='png' ></td>";
}
$i = 'set';
echo '<tr>
      <td width="141" height="25" align="left" valign="middle" ><a href="player.php?id='.$cmember['id_user'].'" class="text_main_5">'.$cmember['name'].' ['.lvl($cmember['exp']).']</a></td>
      <td align="center" valign="middle" ><span class="text_main_4">'.$cmember['clan_stat'].'</span></td>
      <td align="center" valign="middle" ><span class="text_main_4">-</span></td>
      <td align="center" valign="middle" ><span class="text_main_4">'.$zap_gold.'</span></td>
      <td align="center" valign="middle" ><span class="text_main_4">'.$cmember['glory'].'</span></td>
      '.$img_on.'';
        if($boss)
        {echo '<td align="center" id = "'.$i.'" valign="middle"><input type="submit" name="bSet" value="Назначить"></span></td>'; }
        $i++;
        $player = $cmember; 
    '</tr>';

    if (isset($_POST['bSet']))
    {
    echo 'works';
    count_query("UPDATE users SET clan_stat='Вождь' WHERE id_user='".$player['id_user']."'");
    $time = date('j.n.y H:i');
    count_query("INSERT INTO `message` (`time`, `to`, `text`, `metka`) VALUES ('".$time."', '".$player['name']."', 'Вас выбрали главой клана <a href=clan.php>".$clan['name']."</a>', '6')");
    echo "<script>location.href='clan.php'</script>";
    }
}
?>

`

1 个答案:

答案 0 :(得分:0)

您需要将submit的所有内容添加到<form id="yid">... </form>,然后点击onclick="javascript:$('#yid').submit()" yid =您希望按钮提交的表单的特定ID。