prepare($sql); $stmt->execute(); //$count = $stmt->rowCount();// DOES NOT WORK //$count = $stmt->fetch(PDO::FETCH_OBJ); and for loop works echo "
select query worked"; //echo "
row count" . $count; /*** echo number of columns ***/ /*** loop over the object directly ***/ echo "\n"; while($row = $stmt->fetch(PDO::FETCH_OBJ)) { echo "\n"; foreach ($row as $item) { echo "\n"; } //foreach ends } // echo "
".($item !== null ? htmlentities($item, ENT_QUOTES):" ")."
\n"; // //echo " no of rows : ". oci_num_rows($stmt); echo "no.of rows :".$count; /*** close the database connection ***/ $conn= null; // }catch(PDOException $e){ echo ($e->getMessage()); } echo "bye"; ?>