3 /* Testing odbc_num_rows() for display number of rows */
5 $conn=odbc_connect('mycsql','root','manager');
8 echo "Connection Failed";
12 //$sth = odbc_prepare($conn,"CREATE TABLE t1(f1 INT, f2 CHAR(20),primary key(f1));");
13 $sth = odbc_prepare($conn,"CREATE TABLE t1(f1 INT, f2 CHAR(20),f3 SMALLINT,f4 BIGINT,f5 FLOAT, f6 DOUBLE,f7 DATE, f8 TIMESTAMP );");
14 $res = odbc_execute($sth);
17 echo "Error in Creation";
20 echo "Table Created\n";
22 $sth = odbc_prepare($conn,"INSERT INTO t1 VALUES(20,'Twenty',2,10000001,10.01,10000001.000001,'2001-1-1','2001-11-30 01:01:01');");
23 $res = odbc_execute($sth);
26 echo "Error in Creation";
29 echo "Record Inserted\n";
31 $sth = odbc_prepare($conn,"INSERT INTO t1 VALUES(30,'Thirty',3,20000002,20.02,20000002.000002,'2002-2-2','2002-22-30 02:02:02');");
32 $res = odbc_execute($sth);
35 echo "Error in Creation";
38 echo "Record Inserted\n";
40 $sql = 'SELECT * FROM t1;';
41 $result = odbc_exec($conn, $sql);
42 echo "Number of rows = ";
43 $a=odbc_num_rows($result);
46 odbc_exec($conn,"DROP TABLE t1;");
51 $sql = "SELECT f3,f5,f7 FROM t1";
52 $result = odbc_exec($conn, $sql);
54 while (odbc_fetch_row($result))
56 $a=preg_replace('/[\x00-\x09\x0B-\x19\x7F]/', '',odbc_result($result,1));
57 $b=preg_replace('/[\x00-\x09\x0B-\x19\x7F]/', '',odbc_result($result,2));
58 $c=preg_replace('/[\x00-\x09\x0B-\x19\x7F]/', '',odbc_result($result,3));
60 echo "<td>$a</td><td>$b</td><td>$c</td></tr>";
64 $sth=odbc_prepare($conn,"DROP TABLE t1;");
65 $res = odbc_execute($sth);
68 echo "\nError in Drop Table";
71 echo "\nTable Dropped \nTest Passed";