What is mysql fetch assoc in PHP

In this article I am going to explain about mysql_fetch_assoc function in PHP.
  • 2607

PHP mysql_fetch_assoc() Function

The PHP mysql_fetch_assoc function is used to fetch a result row from a recordset as associative array.

Syntax of mysql_fetch_assoc function

mysql_fetch_assoc(data)


Parameters in
mysql_fetch_assoc function

It has only one parameter:
 

Parameter Description
data It specifies which data pointer to use.

Example of mysql_fetch_assoc function

<html>

<body>

<?php

$con=mysql_connect("localhost","gupta","sharad");

if(!$con)

{

die("Could not connect:".mysql_error());

}

$database=mysql_select_db("Mcn_Solution", $con);

$qry="select * from Emp where Id=105";

$result=mysql_query($qry,$con);

print_r(mysql_fetch_assoc($result));

mysql_close($con);

?>

</body>

</html>


Output:

mysql-fetch-assoc-php.jpg

You may also want to read these related articles :
here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.