在循环中的PHP循环 - >但只有一次通过

时间:2014-10-20 17:05:16

标签: php loops mysqli while-loop

$mysqli = new mysqli($dbhost,$dbuser,$dbpass, $dbname);
if (mysqli_connect_errno()) { printf("Keine Verbindung zur Datenbank!: %s\n", mysqli_connect_error()); exit(); }
if (!$mysqli->set_charset("utf8")) { echo "Fehler beim Laden von UTF8 ". $mysqli->error; }

$query_active = "SELECT * FROM `events` WHERE month > $current_month AND year >= $current_year 
OR day >= $current_day AND month = $current_month AND year >= $current_year 
OR year > $current_year 
OR month_show > $current_month AND year_show >= $current_year
OR day_show >= $current_day AND month_show = $current_month AND year_show >= $current_year
OR year_show > $current_year
ORDER BY year, month, day";
$query_all = "SELECT * FROM events ORDER BY year, month, day ASC";

if ($status == "active") { $result = $mysqli->query($query_active) or die($mysqli->error.__LINE__); } else if ($status=="all") { $result = $mysqli->query($query_all) or die($mysqli->error.__LINE__); }
else { $result = $mysqli->query($query_all) or die($mysqli->error.__LINE__); echo "Error! -» NEWS"; }

$result_useraktiv = $mysqli->query("SELECT * FROM Useraktiv") or die($mysqli->error.__LINE__);
?> 
 <tr class=xl671108 height=89 style='mso-height-source:userset;height:66.75pt'>
  <td height=89 class=xl691108 width=48 style='height:66.75pt;width:36pt'>ID</td>
  <td class=xl691108 width=157 style='width:118pt'>Mitglied</td>
<?php
$headerevent = "";
$headeruser = "";
$status = "";
$usereintragfertig = "";

if($result_useraktiv->num_rows > 0) {

$felder = $mysqli->field_count;
$mitglieder = 2; // Startposition Usereinträge WHERE event IN (".join(',',$id).")

while ($mitglieder < $felder){
$finfo = $result_useraktiv->fetch_field_direct($mitglieder++);

$user = $finfo->name; // Usernamen Array

$headeruser .= "<tr class=xl711108 height=35 style='mso-height-source:userset;height:26.25pt'><td height=35 class=xl721108 width=48 style='height:26.25pt;width:36pt'>".$mitglieder."</td>
<td class=xl721108 width=157 style='width:118pt'>".$user."</td>";

while ($row = $result->fetch_assoc()) {
$event = stripslashes($row["event"]);
$headerevent .= "<td class=xl661108 width=96 style='width:72pt'>".$event."</td>";

$id = stripslashes($row['id']);

$result_user = $mysqli->query("SELECT * FROM Useraktiv WHERE event = '$id'") or die($mysqli->error.__LINE__);
while ($usereintrag = $result_user->fetch_assoc()) { // Usereinträge

if ($usereintrag[$user] == "0") { $headeruser .= "<td class=xl701108 width=96 style='width:72pt'>x</td>"; } // Usereinträge
elseif ($usereintrag[$user] == "1") { $headeruser .= "<td class=xl701108 width=96 style='width:72pt'>+</td>"; }
elseif ($usereintrag[$user] == "") { $headeruser .= "<td class=xl701108 width=96 style='width:72pt'>n/a</td>"; }
}}}

为什么它会在下面的循环中显示我只有一段

上面的while循环向我提取用户,循环2在此循环中是给定日期的事件

非常感谢提前的帮助,我一直在寻找永恒的互联网空白

0 个答案:

没有答案