<?php
// Connect to MSSQL
$link = mssql_connect('MANGO\SQLEXPRESS', 'sa', 'phpfi');
mssql_select_db('php', $link);
// Select all people
$result = mssql_query('SELECT [name], [age] FROM [persons] WHERE [age] >= 13');
if(!$result)
{
die('Query failed.');
}
// Select every 4th student in the results
for($i = mssql_num_rows($result) - 1; $i % 4; $i++)
{
if(!mssql_data_seek($result, $i))
{
continue;
}
// Fetch the row ...
}
// Free the query result
mssql_free_result($result);
?>