2013-05-23 2 views
0
<?php 

session_start(); 
$link = mysqli_connect("localhost", "xxx", "xxxxxx", "xxx"); 
/* check connection */ 
if (mysqli_connect_errno()) { 
    printf("Connect failed: %s\n", mysqli_connect_error()); 
    exit(); 
} 

$id = $_GET['id']; 
if ($result = mysqli_query($link, "SELECT * FROM Subscribe WHERE STo = '".$id."' ORDER BY ID LIMIT 6")) { 
    while($row = mysqli_fetch_array($result)) 
    { 
     $idS = $row['SWho']; 
     echo $idS; 
     if ($result = mysqli_query($link, "SELECT * FROM accounts WHERE ID = '".$idS."' ORDER BY ID LIMIT 6")) { 
      while($row = mysqli_fetch_array($result)) 
      { 
       echo "<img src='Member_ProfilePics/"; 
       echo $row['PP'] . '.' . $row['Ext']; 
       echo "' width=42 height=40 style='float: left'>"; 
      } 
     } 
    } 
    //<img src='Member_ProfilePics/john.jpg' width=42 height=40 style='float: left'> 
}        
?> 

여기 내 코드에 STO 목록을 출력하고 싶습니다. 다른 데이터베이스에 연결하여 각 STo에서 다음 행을 출력하십시오.Loop for Arp

(picture of id=1) 1 
(picture of id=2) 2 
(picture of id=3) 3 
(picture of id=4) 4 
(picture of id=5) 5 
(picture of id=6) 6 

방법 :

샘플 출력 될? 내 코드가 루핑되지 않습니다. 내 코드의

샘플 출력 : 두 루프에 대해 같은 변수를 사용하는

(picture of id=1) 1 
+0

'에 seconda 값을 변경하려면 SELECT * FROM STO = ' ". $ id."'ORDER BY ID LIMIT 6 "',이 쿼리는 몇 개의 항목을 반환합니까? – dreamweiver

+0

mysqli_query ($ link, "SELECT * FROM accounts WHERE ID = '"$ idS ",'주문 번호 ID LIMIT 6 ')의 결과는 무엇입니까? –

답변

2

:

if ($result = mysqli_query($link, "SELECT * FROM Subscribe WHERE STo = '".$id."' ORDER BY ID LIMIT 6")) { 
    while($row = mysqli_fetch_array($result)) { 

     .... 

     if ($result = mysqli_query($link, "SELECT * FROM accounts WHERE ID = '".$idS."' ORDER BY ID LIMIT 6")) { 
      while($row = mysqli_fetch_array($result)) { 
       ... 
      } 
     } 
    } 
} 

봅니다이

if ($result = mysqli_query($link, "SELECT * FROM Subscribe WHERE STo = '".$id."' ORDER BY ID LIMIT 6")) { 
    while($row = mysqli_fetch_array($result)) { 

     .... 

     if ($result2 = mysqli_query($link, "SELECT * FROM accounts WHERE ID = '".$idS."' ORDER BY ID LIMIT 6")) { 
      while($row2 = mysqli_fetch_array($result2)) { 
       ... 
      } 
     } 
    } 
} 
+0

대단히 고마워요! :) –

+0

그냥 기다려 .. icant voteup .. :) –