需要计算在PHP中创建的列表的结果

Okay I have a list being populated and echoed out on a page.

$sql = "SELECT * FROM `game_toe` WHERE `owner`='$mech_units'";
$mydata = mysql_query($sql);

while($record = mysql_fetch_array($mydata)){

echo "<td>" . $record['units'] . "</td>";

Now the results fluctuate depending on the number of 'mech_units' there are. What I need is to display how many are being displayed in the list. Any suggestions?

First of all, I would suggest using mysqli.

You could declare a variable which increases by one every time you echo a 'mech_unit'.

$sql = "SELECT * FROM `game_toe` WHERE `owner`='$mech_units'";
$mydata = mysql_query($sql);

$i = 0;

while($record = mysql_fetch_array($mydata)){

    $i++;

    echo "<td>" . $record['units'] . "</td>";

}

echo "There are " . $i . " mech_units.";

Another option would be to use the mysql_num_rows() function.

you can use built in function mysql_num_rows($mydata). This will give you the total number of records that are fetched.