我对此非常接近,但仍然遇到事件列表问题。我正在寻找的是标题,日期和事件,以及参加该事件的名单列表。现在我得到的事件,日期和标题打印的次数与名称相同,每个都只显示一个名称。
我在几个领域尝试过GROUP BY,但似乎没什么用。
current
这就是我现在所得到的:undesired
这就是我想要的:desired
答案 0 :(得分:0)
我可能做的是让一个变量表示“此行中的数据是否与新事件相对应,还是同一事件的附加数据?”
如果日期不匹配,那就是新事件;首先,添加一个新的标题行,然后添加一个包含所有四列数据的新行。如果日期匹配,则跳过标题并添加一行,前三列为空,第四列为新名称。 (抱歉,如果我的PHP没有完全编译,那已经有一段时间了。)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button type="button" onclick="getPostData()">Collect data</button>
<table align=center>
<thead>
<tr>
<th>Skating</th>
<th>Shooting</th>
<th>Passing</th>
<th>Puck Control</th>
<th>Team Play</th>
<th>Overall</th>
</tr>
</thead>
<tbody>
<tr class="item" data-id="1">
<td>
<input type="radio" name="skating" value="1">1
<input type="radio" name="skating" value="2">2
<input type="radio" name="skating" value="3">3
<input type="radio" name="skating" value="4">4
<input type="radio" name="skating" value="5">5
<br>
<input type="radio" name="skating" value="6">6
<input type="radio" name="skating" value="7">7
<input type="radio" name="skating" value="8">8
<input type="radio" name="skating" value="9">9
<input type="radio" name="skating" value="10">10
</td>
<td>
<input type="radio" name="shooting" value="1">1
<input type="radio" name="shooting" value="2">2
<input type="radio" name="shooting" value="3">3
<input type="radio" name="shooting" value="4">4
<input type="radio" name="shooting" value="5">5
<br>
<input type="radio" name="shooting" value="6">6
<input type="radio" name="shooting" value="7">7
<input type="radio" name="shooting" value="8">8
<input type="radio" name="shooting" value="9">9
<input type="radio" name="shooting" value="10">10
</td>
<td>
<input type="radio" name="passing" value="1">1
<input type="radio" name="passing" value="2">2
<input type="radio" name="passing" value="3">3
<input type="radio" name="passing" value="4">4
<input type="radio" name="passing" value="5">5
<br>
<input type="radio" name="passing" value="6">6
<input type="radio" name="passing" value="7">7
<input type="radio" name="passing" value="8">8
<input type="radio" name="passing" value="9">9
<input type="radio" name="passing" value="10">10
</td>
<td>
<input type="radio" name="puck_control" value="1">1
<input type="radio" name="puck_control" value="2">2
<input type="radio" name="puck_control" value="3">3
<input type="radio" name="puck_control" value="4">4
<input type="radio" name="puck_control" value="5">5
<br>
<input type="radio" name="puck_control" value="6">6
<input type="radio" name="puck_control" value="7">7
<input type="radio" name="puck_control" value="8">8
<input type="radio" name="puck_control" value="9">9
<input type="radio" name="puck_control" value="10">10
</td>
<td>
<input type="radio" name="team_play" value="1">1
<input type="radio" name="team_play" value="2">2
<input type="radio" name="team_play" value="3">3
<input type="radio" name="team_play" value="4">4
<input type="radio" name="team_play" value="5">5
<br>
<input type="radio" name="team_play" value="6">6
<input type="radio" name="team_play" value="7">7
<input type="radio" name="team_play" value="8">8
<input type="radio" name="team_play" value="9">9
<input type="radio" name="team_play" value="10">10
</td>
<td class="overall"></td>
</tr>
<tr class="item" data-id="2">
<td>
<input type="radio" name="skating" value="1">1
<input type="radio" name="skating" value="2">2
<input type="radio" name="skating" value="3">3
<input type="radio" name="skating" value="4">4
<input type="radio" name="skating" value="5">5
<br>
<input type="radio" name="skating" value="6">6
<input type="radio" name="skating" value="7">7
<input type="radio" name="skating" value="8">8
<input type="radio" name="skating" value="9">9
<input type="radio" name="skating" value="10">10
</td>
<td>
<input type="radio" name="shooting" value="1">1
<input type="radio" name="shooting" value="2">2
<input type="radio" name="shooting" value="3">3
<input type="radio" name="shooting" value="4">4
<input type="radio" name="shooting" value="5">5
<br>
<input type="radio" name="shooting" value="6">6
<input type="radio" name="shooting" value="7">7
<input type="radio" name="shooting" value="8">8
<input type="radio" name="shooting" value="9">9
<input type="radio" name="shooting" value="10">10
</td>
<td>
<input type="radio" name="passing" value="1">1
<input type="radio" name="passing" value="2">2
<input type="radio" name="passing" value="3">3
<input type="radio" name="passing" value="4">4
<input type="radio" name="passing" value="5">5
<br>
<input type="radio" name="passing" value="6">6
<input type="radio" name="passing" value="7">7
<input type="radio" name="passing" value="8">8
<input type="radio" name="passing" value="9">9
<input type="radio" name="passing" value="10">10
</td>
<td>
<input type="radio" name="puck_control" value="1">1
<input type="radio" name="puck_control" value="2">2
<input type="radio" name="puck_control" value="3">3
<input type="radio" name="puck_control" value="4">4
<input type="radio" name="puck_control" value="5">5
<br>
<input type="radio" name="puck_control" value="6">6
<input type="radio" name="puck_control" value="7">7
<input type="radio" name="puck_control" value="8">8
<input type="radio" name="puck_control" value="9">9
<input type="radio" name="puck_control" value="10">10
</td>
<td>
<input type="radio" name="team_play" value="1">1
<input type="radio" name="team_play" value="2">2
<input type="radio" name="team_play" value="3">3
<input type="radio" name="team_play" value="4">4
<input type="radio" name="team_play" value="5">5
<br>
<input type="radio" name="team_play" value="6">6
<input type="radio" name="team_play" value="7">7
<input type="radio" name="team_play" value="8">8
<input type="radio" name="team_play" value="9">9
<input type="radio" name="team_play" value="10">10
</td>
<td class="overall"></td>
</tr>
</tbody>
</table>
另外,我不确定你真正想要的是单独的表格;如果是这样,那么在第一个$lastEventDate = '';
Print "<table width=500>";
while($info = mysql_fetch_array( $data ))
{
if ($lastEventDate != $info['date'])
{
Print "<tr>";
Print
"<th style='width:225px;' bgcolor=#49A78D align=center >Title</th>
<th style='width:300px;' bgcolor=#49A78D align=center >Text</th>
<th style='width:175px;' bgcolor=#49A78D align=center >Date</th>
<th style='width:175px;' bgcolor=#49A78D align=center >Name</th>";
Print "</tr>";
}
Print "<tr>";
if ($lastEventDate == $info['date'])
{
Print "<td colspan=3 />"
}
else
{
Print
"<td bgcolor=#ffffff valign=top align=center>".$info['title'] . "</td>
<td bgcolor=#ffffff valign=top align=left>".$info['text'] . "</td>
<td bgcolor=#ffffff valign=top align=left>".$info['date'] . "</td>"
}
Print "<td bgcolor=#ffffff valign=top align=left>".$info['name'] . "</td>";
Print "</tr>";
$lastEventDate = $info['date'];
}
块内,您可以关闭第一个表,然后打开一个新表。