나는 PHP를 통해 야구 팀 라인업을 인쇄하고 있습니다. 누락 된 플레이어 6 (또는 누락 된 위치)에 대한 자리 표시자를 인쇄하고 싶습니다.조건이있는 경우 인쇄 배열
플레이어 1 -> 플레이어 5가 정상적으로 인쇄되면 플레이어 6이 아닌 인쇄소 소유자, 플레이어 7 -> 플레이어 9가 정상입니다 인쇄. 나는 코드를 단순화하려고 노력했다. 나는이 모든 방법으로이 문제를 해결하려고 노력했지만 계속 붙어 있습니다.
CODE:
$rot = array();
$pos = array();
$jn = array();
$x = 1;
// loads up the arrays from the db
while ($rot[$x], $pos[$x], $jn[$x])= $r->fetch_row()) {
$x++;
}
// counts the actual number of players in linuep
// used for validation and error display
$num_players = mysqli_num_rows($r);
// controls the lineup position
for ($i = 1; $i <= 15; $i++){
if($rot[$i] == $i) {
//prints player
$lineup .= "<div data-fp='" . $pos[$i] . "'>" .$jn[$i]. "</div>";
} else {
// prints place holder
$text = "This Position needs to be filled before the next game.";
$lineup .= "<div id='pid' data-rel='".$text."' data-fp='' data-pid='' data-jn='' title=''>x</div>";
}
}
는 또한 일치하는 위치를 발견하고 광고를 출력하도록 배열 ROT [] 반복이 시도하지만 실제로 반복 홀더를 출력한다.
// controls the lineup position
for ($x = 1; $x <= 15; $x++){
for ($i = 1; $i <= ($num_players+1); $i++) {
if ($x == $i) {
//prints player
$lineup .= "<div data-fp='" . $pos[$i] . "'>" .$jn[$i]. "</div>";
} else {
// prints place holder
$text = "This Position needs to be filled before the next game.";
$lineup .= "<div id='pid' data-rel='".$text."' data-fp='' data-pid='' data-jn='' title=''>x</div>";
}
}
}
아무도 아무것도 말하지 않는 더 자세한 설명 변수 이름, $ 부패, $의 요, $ 볼때, $ r을 사용하십시오. – thedaian
@thedaian : 오, 그것은 나에게 뭔가를 말하고 있습니다. –
이것은 JavaScript와 어떤 관련이 있습니까? –