I am using ms sql and php.
What I am trying to do is display all the records that have the same incident number. I can get the first one to load, but im stuck how to get the rest of them.
<?php
$serverName = "myserver";
$connectionOptions = array("Database"=>"mydb");
$conn = sqlsrv_connect( $serverName, $connectionOptions);
$dir ='/uploads';
error_reporting(E_ALL);
$tsql = "SELECT comments,photoname FROM reports where incident like 'teststring'";
$stmt = sqlsrv_query( $conn, $tsql);
if( $stmt === false )
{
echo "Error in statement preparation/execution.\n";
die( print_r( sqlsrv_errors(), true));
}
/* Make the first row of the result set available for reading. */
if( sqlsrv_fetch( $stmt ) === false )
{
echo "Error in retrieving row.\n";
die( print_r( sqlsrv_errors(), true));
}
$name = sqlsrv_get_field( $stmt, 0);
echo "$name: ";
$stream = sqlsrv_get_field( $stmt, 1,
SQLSRV_PHPTYPE_STREAM( SQLSRV_ENC_CHAR));
while( !feof( $stream))
{
$str = fread( $stream, 10000);
//echo $str;
}
echo '<img src="'. $dir. '/'. $str. '" height="200" width="200"/>';
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);
?>