dssqq82402 2015-06-27 08:01
浏览 15

使用PHP将数据从html表添加到表单中

First of all, i have a complicated table with values resulted from queries.The table is displayed as wanted http://i58.tinypic.com/dux5i.jpg . What i'm trying to do.. is use the variable $posibilitate into a second query after the button is pressed so i can echo it into the div with id="belet". The part after if($_POST['butonel']) isn't working as intended, it only displays the last value from the second query . This is how my table posibilitate looks like: http://i57.tinypic.com/t4y71f.jpg. Below you have my full script of the page.

 <?php
 $idcompetitie=$_GET['idcompetitie'];
 $sql="SELECT  idpariu, titlu, data_sfarsit from pariu WHERE idcompetitie=".$idcompetitie;
 $resursa=mysql_query($sql);
 while($row=mysql_fetch_array($resursa))
{
?>
 <tbody id="belet">
 <tr>
 <td class="meciuri" width="210px"  align="left" color="#666666">
 <?php echo $row['titlu']?> </td>
 <td class="data" width="120px" align="center" >
 <?php echo $row['data_sfarsit']?>
 </td>

 <td class="cote" align="right">
 <?php
 if($idcompetitie)
 {
 $sql1="select cota, idposibilitate from posibilitate where idpariu=".$row['idpariu'];
 $resursa1=mysql_query($sql1) or die(mysql_error());

while($row1=mysql_fetch_array($resursa1))
        {
  $cota=$row1['cota'];
  $posibilitate=$row1['idposibilitate'];
 $_SESSION['poss']=$row1['idposibilitate']; 
 echo "<td class='odds' id='$posibilitate'  ><form action='' method='post'> <input type='submit' name='butonel' value='$cota'/></form></td>" ;

if($_POST['butonel'])     
{
$sql2="SELECT titlu, data_sfarsit, idposibilitate, numeposibilitate, cota FROM posibilitate , pariu  WHERE posibilitate.idpariu=pariu.idpariu AND posibilitate.idposibilitate='$posibilitate'";
$resursa2=mysql_query($sql2) or die(mysql_error());
while ($row2=mysql_fetch_array($resursa2))
{
$posibilitati= $row2['cota'];
$idpos=$row2['idposibilitate'];
$datapos=$row2['data_sfarsit'];
$numepos=$row2['numeposibilitate'];
$titlul=$row2['titlu'];
$cotapos=$row2['cota'];

$belet = "<form action='' method='post'>
<input type='text' name='posibilitate' value='$idpos'/>
<input type='text' name='titlu' value='$titlul' /><br/>
<input type='text' name='cota' value='$cotapos'/>
<input type='submit' name='button' value='x' /><br/>
    </form>";
}
}
                }
} 
 ?>
</td>
</tbody>
</tr>
<?php
}
?>
</table>
</td>
</div>
<div id="belet">
<?php
 echo $belet;
 ?>

I've been trying to use arrays or a different php file but i can't seem to get that variable $posibilitate working for the next query.

Thanks for reading, any suggestions would be really helpfull.

  • 写回答

2条回答 默认 最新

  • dqu94359 2015-06-27 08:11
    关注

    After 1st query, your $posibilitate only save the last $row1 value. So when you clicked your "button1" => you only have the last $row1 value. That's all i can help. I don't understand what you want to do with this code.

    评论

报告相同问题?

悬赏问题

  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答
  • ¥20 在本地部署CHATRWKV时遇到了AttributeError: 'str' object has no attribute 'requires_grad'