MYSQL PHP:我怎么能找到总数。 连续的列?

$result = mysql_query("select * from formtable") or die("Records could not be fetched");
    while($row=mysql_fetch_row($result))  
    { 
           echo $row[0].$row[1].$row[2];
    }

The above code runs perfect. But i find this statement -> echo $row[0].$row[1].$row[2] bit too static. Because if a new column is added i will have to modify the code as echo $row[0].$row[1].$row[2].$row[3].

So, How can i count total columns of the row in order to avoid such a problem?

Better to use something like:-

foreach($row AS $column)
{
echo $column;
}

mysql_num_fields() is what you're looking for.

Just to not leave it unspoken; the mysql_* family functions are deprecated, for new code you should use mysqli or PDO.

You can use count($row) to find the number of fields. But it is better to use a foreach loop as previously suggested.

Wouldn't it make more sense to use something like this:

echo implode($row);

No need to use a loop when there's a function that does it for you...