如何获取具有特定ID的行之后的表中的行数?

how do i get the number of rows in an sql table that come after a row with a specific id with php? I want to get the number of rows that come after the row with an id of 6.

Select count(*) from TableName where ID > 6

The SQL for a query to count the rows with an ID greater than 6, assuming your table is named table and the ID column is named id will be:

SELECT count(*) FROM table WHERE id > 6;

To do this from PHP, you can modify the example in the docs to add your own query. The output could also be tweaked to return a scalar value.

<?php
// Connecting, selecting database
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
    or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('my_database') or die('Could not select database');

// Performing SQL query
$query = 'SELECT count(*) FROM table WHERE id > 6';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

// Printing results in HTML
echo "<table>
";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
    echo "\t<tr>
";
    foreach ($line as $col_value) {
        echo "\t\t<td>$col_value</td>
";
    }
    echo "\t</tr>
";
}
echo "</table>
";

// Free resultset
mysql_free_result($result);

// Closing connection
mysql_close($link);
?>