Scanning involves the sequential navigation of the records in a result set. Scanning is often done when you want to manually insert HTML based on your result set into the stream that is inserted in place of the PHP commands.
The following PHP commands are located in the showproducts.php script. These commands produce an HTML form that includes one radio button for each product found in the PRODUCT table. Because of the action attribute of the HTML form, the product code of the selected product name will be appended to the query string part of the HTTP GET command that will be submitted to the showproducts.php script.
$rConn = ads_connect( "DataDirectory=\\\\server\\share\\".
"adsuser", "password" );
$rStmt = ads_prepare( $rConn, "SELECT [Product Name], ".
"[Product Code] FROM Products" );
$rResult = ads_execute( $rStmt );
while ( ads_fetch_row( $rStmt ) )
$strProductName = ads_result( $rStmt, "Product Name" );
$strProductCode = ads_result( $rStmt, "Product Code" );
echo "<INPUT Type = \"radio\" Name = \"rb\" Value = \"" .
trim( $strProductCode ) . "\" > " .
$strProductName . "<br>\n";
ads_close( $rConn );
When this PHP file is processed, it produces the Web page shown in Figure 19-6.
Figure 19-6: The output from showproducts.php