OK 그래서 SQL Server 2008에서 PHP를 통해 html 테이블로 작업에 대한 데이터를 가져옵니다. 각 작업은 여러 작업을 수행 할 수 있습니다. 나는 while 루프를 사용하고있다. (while 'outer'while) 그리고 다른 루프는 이전 루프의 셀들 중 하나의 작업을 보여준다. 나는 'inner'while 루프를 빠져 나왔지만 'outer'while 루프의 다음 라운드는 트리거하지 않는다는 것을 발견했다. 모든 것이 작동하는 동안 나는 내부를 주석 처리합니다.While 루프 while 루프 문제
$sql = "SELECT * FROM [euroJobSrv].[dbo].[Job],[euroJobSrv].[dbo].[Site]";
$result = dbQuery($sql);
while($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)){
$sql1 = "SELECT Task_Type FROM [euroJobSrv].[dbo].[JobTask] WHERE Task_Job_ID='".$row['Job_ID']."'";
$result1 = dbQuery($sql1);
$Site_Address = str_replace(',', ', <br>', $row['Site_Address']);
$days = $row['Job_Finish_Date'] - $row['Job_Start_Date'] + '1';
echo " <tr>
<th width=50> Job ID: </th>
<th width=50> Site Address:</th>
<th width=50> Start Date: </th>
<th width=50> Finish Date: </th>
<th width=50> Days: </th>
<th width=50> Overnight: </th>
<th width=50> Tasks: </th>
</tr>";
echo " <tr>
<td width=50>".$row['Job_ID']."</td>
<td width=50>".$Site_Address."</td>
<td width=50>".$row['Job_Start_Date']."</td>
<td width=50>".$row['Job_Finish_Date']."</td>
<td width=50>".$days."</td>
<td width=50>".$row['Job_Overnight']."</td>
<td width=50><ul>";
while ($row1 = sqlsrv_fetch_array($result1, SQLSRV_FETCH_ASSOC)){
echo "<li>".$row1['Task_Type']."</li>";}
echo" <ul></td>
<td><a href='include/job/modify.php?j=".$row['Job_ID']."'>modify</a></td>
</tr>";
}
[PHP - 중첩 된 mysql_fetch_array() 문제로 인해 나를 미치게 만들 수 있음] (http://stackoverflow.com/questions/2277855/php-problem-with-nested-mysql-fetch-array-driving-me- 미친) – marcog
sqlsrv 드라이버에는 비슷한 결과를 보이는 data_seek 함수와 비슷한 기능이 없습니다. 비슷한 예제 – Rob