2017-04-21 1 views
0

데이터베이스에서 ID 열을 순차적으로 가져 오려고합니다. 이 코드를 작성했지만 작동하지 않습니다.PHP 알림 : 정의되지 않은 오프셋 1

주의 사항 :

$connection = mysqli_connect($servername,$username,$password,$dbname); 
if(!$connection) 
    die("Database connection failed: " . mysqli_connect_error()); 

$query = "SELECT ID FROM channel "; 

if($result = mysqli_query($connection,$query)) 
{ 
    $count = mysqli_num_rows($result);// it will start from the first row and continue with others... 
    //fetch one and one row 
    while($row=mysqli_fetch_row($result)) 
    { 
     for($i=0; $i<$count; $i++) 
     echo "<a>$row[$i]</a>"; 
    } 
    //free result set 
    mysqli_free_result($result); 

} 
mysqli_close($connection); 

그래서,이 코드는 날이 오류를 제공 오프셋 정의 : C 1 : \ XAMPP \ htdocs를 \된다 \ fetch_channel.php 라인 (24)

누구든지 나를 도울 수 그것에 대해 ?

+0

안녕, 유 알려 주시기 바랍니다 수 있습니다 당신은 24 줄에 넣었습니다. –

답변

0

문제는 다음과 같습니다이 당신이 원하는 모르겠어요 $ 행 에는 $의 전 지수는 없지만, 난 당신이 이런 식으로 뭔가하고 싶은 생각 :

$connection = mysqli_connect($servername,$username,$password,$dbname); 
if(!$connection) 
    die("Database connection failed: " . mysqli_connect_error()); 

$query = "SELECT ID FROM channel "; 

if($result = mysqli_query($connection,$query)) 
{ 

    //fetch one and one row 
    while($row=mysqli_fetch_row($result)) 
    { 

     echo "<span>".$row['id']."</span><br/>"; 
    } 


} 
mysqli_close($connection); 
+0

감사합니다. :) – Serhat

관련 문제