2
    $stmt =$this->db->prepare("select * from abstract where account_name=:account_name");
    $stmt->bindparam(':account_name',$name);
    $stmt->execute();
    $getAccountInfo=$stmt->fetchAll();
    return $getAccountInfo;

csv file concept is

if (isset($_POST['xyz'])) {
    $randnum = rand(1111111111,9999999999);

    if (isset($data['0'])) {
        $fp= fopen("contacts_$randnum.csv","w");
        foreach ($data AS $values) {
            fputcsv($fp, $values);
        }
        fclose($fp);
    }
}

when i submit post request i am getting csv file with duplicate column

enter image description here

3
  • 1
    Just checking this is correct (not a fix) if(isset($data['0'])){. Did you mean $data[0]? Commented Feb 12, 2016 at 12:24
  • 1
    PXgamer is correct, remove the single quotes Commented Feb 12, 2016 at 12:26
  • still i am getting same record,i can remove if concept then also i can able to create csv file Commented Feb 12, 2016 at 12:31

1 Answer 1

2

Try

$getAccountInfo=$stmt->fetchAll(PDO::FETCH_ASSOC);
Sign up to request clarification or add additional context in comments.

4 Comments

@ArifKhan No problem Arif
This is only 50% of a good answer. It's missing an explanation of what leads to the OP's unexpected behaviour. "Try x/y" has no learning effect, only copy paste.
@DanFromGermany Thanks for your response. some time we need to have only idea regard the problem. Then we can collect more information by themselves.
@ArifKhan To gather ideas and clearify the problem you have the comments section.

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.