<html> <h2>Demo 7 - Select rows using a cursor</H2> <?php /*********************************************************************/ function chk_ifx_err1($result_id) /*********************************************************************/ { /************************************************** The ifx_error function return the following string: x [SQLSTATE = aa bbb SQLCODE=cccc] where x = space : no error E : error N : no more data W : warning ? : undefined *************************************************/ $err_string = ifx_error($result_id); if ($err_string[0] != ' ') { printf("<BR>Informix error: %s", ifx_errormsg()); die; } } $database = "video"; $server = "lapdog_tcp"; $login = "username"; $password = "password"; $dbs = $database . "@" . $server; $connect_id = ifx_pconnect($dbs,$login,$password); if (!$connect_id) { echo "Unable to connect to Informix database<br>\n"; chk_ifx_err1($connect_id); } else { echo "Informix connection successful! <BR><BR>"; } if ($connect_id) { $statmt_txt = "select first 5 * from vhs where type_code = 'ST1' order by title"; $statmt_id = ifx_prepare($statmt_txt,$connect_id,IFX_SCROLL); // PREPARE SELECT if (!$statmt_id) { chk_ifx_err1($statmt_id); } $ret_val = ifx_do($statmt_id); // EXECUTE PREPARED STATEMENT if (!$ret_val) { chk_ifx_err1($statmt_id); } echo "<table border=5 cellspacing=0 cellpadding=5 bgcolor=cornsilk>"; echo "<tr BGCOLOR='deepskyblue'>"; echo "<td><b><center>Serial ID</center></b></td>"; echo "<td><b><center>Type Code</center></b></td>"; echo "<td><b><center>Tape Number</center></b></td>"; echo "<td><b><center>Title</center></b></td>"; echo "<td><b><center>Hours</center></b></td>"; echo "<td><b><center>Comment</center></b></td>"; echo "<td><b><center>Modify</center></b></td>"; echo "</tr>\n"; while ($row = ifx_fetch_row($statmt_id,"NEXT")) { $serial_id = $row[serial_id]; $type_code = chop($row[type_code]); $tape_num = $row[tape_num]; $title = chop($row[title]); $hours = $row[hours]; $comment = chop($row[comment]); echo "<tr>\n"; echo "<td><center>$serial_id</td>"; echo "<td><center>$type_code</td>"; echo "<td><center>$tape_num</td>"; echo "<td>$title</td>"; echo "<td>$hours</td>"; echo "<td>$comment</td>"; echo "</tr>\n"; } echo "</table>"; } ?> </html>