Lets think we have a table with following fields,
id
name
age
Now when you use mysql_fetch_array() it will return both numeric array and an associative array.
while($data = mysql_fetch_array($result))
{
//will return
$id = $data[0];
$id = $data['id'];
$name = $data[1];
$name = $data['name'];
$age = $data[2];
$age = $data['age'];
}
when you use mysql_fetch_assoc() it will return only an associative array.
while($data = mysql_fetch_assoc($result))
{
// will return
$id = $data['id'];
$name = $data['name'];
$age = $data['age'];
}
So mysql_fetch_assoc() is comparatively faster because its only return a associative array.
Get Free Sinhala IT Learning Videos Kuppiya.com
No comments:
Post a Comment