CODE
$sql = "SELECT DISTINCT MATCH(name) Against ('$search' IN BOOLEAN MODE) as score, name FROM pdfdb WHERE MATCH(name) Against ('$search' IN BOOLEAN MODE) ORDER BY score DESC";
$query = mysql_query($sql) or die(mysql_error());
$row_sql = mysql_fetch_assoc($query);
$total = mysql_num_rows($query);
echo "Number of rows found: ".$total;
if($total>0) {
while ($row_sql = mysql_fetch_assoc($query)) {//echo out the results
echo ''.$row_sql['name'].'<br />';
}
} else
{
echo "No results to display";
}
Yep, Martyr got it. mysql_fetch_assoc fetches an associative array (similar to mysql_fetch_array, which fetches an indexed array). When used on a multi-row query, it fetches the array, then moves on to the next row. That's how the while loop works, once there are no more rows to fetch the statement is false, that way it doesn't go on forever.
Also just as a sidenote, variables will expand when in double quotes. So your echo statements could become
echo "$row_sql[name] <br />";echo "Number of rows found: $total";etc.
Just thought I'd point that out