0
//getting values from dataBase
$sql = "SELECT  `email` ,  `password` FROM  `user_inf`";
// Execute query
$result = mysql_query($sql,$con);
$email;
$pass;

while($row = mysql_fetch_array($result))
{
$email = $row['email'];
$pass  = $row['password'];
}



// create a dummy array
$doc = array (
1 => array ("Email", "Password")
     array ($email, $pass),
);

I need to fill that array "doc" dynamically .The value I am getting from database and fetching using that while loop.I want to put all those value in that array

1 Answer 1

2

Just do it like this:

$result = mysql_query( "SELECT  `email` ,  `password` FROM  `user_inf`", $con );
$doc = array( array( "Email", "Password" ) );
while( $row = mysql_fetch_array( $result ) ) {
    $doc[] = array( $row['email'], $row['password'] );
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Eugene Manuilov Thanks a lot.Why some one down voted you your ans in correct

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.