Home Tutorial Php Phppdo Tutorial PDO Fetch Num


Share on Google+Share on Google+
PDO Fetch Num
Posted on: April 5, 2010 at 12:00 AM
In this tutorial we will study about PDO Fetch Num in PHP, how to access MySQL using PDO Fetch Num function, How to retrieve data etc. Examples will make this clearer.

PDO Fetch Num:

We've discussed in the previous tutorial about PDO::FETCH_ASSOC, similarly PDO provides another function which returns the numerical index of the result unlike the PDO::FETCH_ASSOC which returns the name of the field. To make the differences clear please compare the previous result and the result given below, you'll find that the result of the  current tutorial is in numeric form.








$dbh=new PDO("mysql:host=$hostname;dbname=ajax",$user,$password);

$sql="select * from student";



echo "<table border=1>";

foreach($result as $key=>$val){

echo "<tr><td>".$key."</td>";

echo "<td>".$val."</td></tr>";}

echo "</table>";


catch(PDOException $c){

echo $c->getMessage(); }




Related Tags for PDO Fetch Num:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 5, 2010

Recommend the tutorial

Advertisements Advertisements