0
텍스트 파일을 통해 php로 채워진 표가 있습니다. 각 새 데이터 항목에 대해 새 테이블을 만드는 방법을 알고 있지만 완전히 새로운 테이블 대신 새 행을 만들려고합니다. 전체 테이블 대신 데이터를 사용하여 새 행을 만들려면 어떻게해야합니까?PHP를 사용하여 데이터로 새 테이블 행 만들기
이것은 현재 현재 가지고있는 변수이며 그 안에 변수가있는 새로운 행을 만들고 싶습니다. 매번 완전히 새로운 테이블을 만들지 않고 어떻게 이것을 할 수 있습니까? 나는 성공하지 못한 채 두 가지 시도를 해왔다. 테이블 행을 생성하는
$tracreport = $tracreport . "<table width='100%' cellpadding='0' cellspacing='0' style='margin-top:15px; background-color:#000; color:#FFF;'>
<tr>
<td style='padding: 3px 0px 3px 0px; font-size: .9em; text-align: center; color: #00FF00;'> Tracking " . $tnumber[1] . " active storm cell</td>
</tr>
<tr>
<td>
<table width='100%' cellpadding='0' cellspacing='0'>
<tr>
<td>
<table id='tracReport' width='100%' cellpadding='0' cellspacing='0'>
<tr>
<td style='background-color:#333; color:#3299cc; font-weight: normal; border: 1px #666 solid; text-align: center; font-size: .9em;'>Cell ID</td>
<td style='background-color:#333; color:#3299cc; font-weight: normal; border: 1px #666 solid; text-align: center; font-size: .9em;'>Tracking Since</td>
<td style='background-color:#333; color:#3299cc; font-weight: normal; border: 1px #666 solid; text-align: center; font-size: .9em;'>Bearing</td>
<td style='background-color:#333; color:#3299cc; font-weight: normal; border: 1px #666 solid; text-align: center; font-size: .9em;'>Distance</td>
<td style='background-color:#333; color:#3299cc; font-weight: normal; border: 1px #666 solid; text-align: center; font-size: .9em;'>Intensity</td>
<td style='background-color:#333; color:#3299cc; font-weight: normal; border: 1px #666 solid; text-align: center; font-size: .9em;'>Trend</td>
<td style='background-color:#333; color:#3299cc; font-weight: normal; border: 1px #666 solid; text-align: center; font-size: .9em;'>Last Strike</td
</tr>
<tr>
<td style='background-color: black; color: #FFF; border: 1px #666 solid; text-align: center; font-size: .9em;'>" . $tid[$k] . "</td>
<td style='background-color: black; color: #FFF; border: 1px #666 solid; text-align: center; font-size: .9em;'>" . $tdtime[$k] . "</td>
<td style='background-color: black; color: #FFF; border: 1px #666 solid; text-align: center; font-size: .9em;'>" . $tdirection[$k] . " °</td>
<td style='background-color: black; color: #FFF; border: 1px #666 solid; text-align: center; font-size: .9em;'>" . $tdistance[$k] . " miles</td>
<td style='background-color: black; color: #FFF; border: 1px #666 solid; text-align: center; font-size: .9em;'>" . strtolower($tintensity[$k]) . "</td>
<td style='background-color: black; color: #FFF; border: 1px #666 solid; text-align: center; font-size: .9em;'>" . trim(strtolower($ttrend[$k])) . "</td>
<td style='background-color: black; color: #FFF; border: 1px #666 solid; text-align: center; font-size: .9em;'>" . trim(strtolower($tactivity[$k])) . "</td>
</tr>
</table>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>";
당신이 보여줄 수있는 최대 수를 알 수있는 것입니다
foreach는 루프를 사용 표? 현재 테이블을 3 개의 변수 테이블 시작, 복제하려는 행 및 테이블 끝으로 분할해야하는 것처럼 보입니다. 그런 다음 루프를 수행 할 수 있습니다 (for foreach, while -). 원하는만큼 많은 행을 작성/추가 할 수 있습니다. – Sean
테이블은 원래 게시물에 있습니다. 당신이 제안하고있는 것을 보여주는 예를 보여줄 수 있습니까? – Texan78
반복 할 행은 무엇입니까? '
답변
당신은 당신의 테이블을 분할 시도하고 중간
편집에 루프를 추가 할 수 있습니다를
대신 당신이 총 최대 모르는 경우3210,이 다음 필요없이 각각의 값을 통해 루프이 구축하는 방법을
출처
2013-07-11 04:37:03 Sean
이것은 위대하고 정확하게 내가 뭘 찾고 있지만 가능한 최대 행을 설정하는 대신 필요에 따라 새 행을 추가 할 수 있습니다. 그렇지 않으면 숫자에 대한 행을 채울 수있는 데이터가 충분하지 않은 경우 unpopulated 행을 보여줍니다 – Texan78
예, 가장 쉬운 방법은 아마도 foreach로 변경 될 것입니다. 위에서 편집 할 것입니다. – Sean
이 방법을 사용 :
출처
2013-07-11 03:27:11 gayan
이것은 데이터베이스를 사용하지 않으므로 작동하지 않습니다. 스크립트는 텍스트 파일을 읽고 텍스트 파일에서 파싱하는 변수로 셀을 채 웁니다 . – Texan78
관련 문제