while循环只读取第一个匹配而忽略其他匹配

The problem is the code skips the first echo statement no matter what.

$query = mysql_query("SELECT index_no, lesson FROM c8_lessons_list WHERE   index_no ='456'");

($row = mysql_fetch_array($query));

if ($row['index_no'] !== '456' && $row['lesson'] !== "Fertilisation process"  )
{
    echo '<a href="file:///D|/CC-Gate/localhost">Fertilisation process</a>';
}
else
{
    echo 'Fertilisation process Completed';
}

try this:

<?php
while ($row = mysql_fetch_array($query)) {

    if ($row['index_no'] !== '456' && $row['lesson'] !== "Fertilisation process") { // this is redundant as  your query handles this
        echo '<a href="file:///D|/CC-Gate/localhost">Fertilisation process</a>';
    } else {
        echo 'Fertilisation process Completed';
    }
}

your query selects rows with index_no='456'

in your if statement:

$row['index_no'] !== '456'

will always return false since what you select from the database will always have:

$row['index_no'] == '456'

... I'm not sure what you want to do exactly but thats is the problem with your code.

also there is no loop in your code. the if statement will happen only once.

You missing loop.

Do like this.

while(($row = mysql_fetch_array($query))){

//if else code goes here
}