Hi Members,
I am search for the reason for the problem why my mysql query cannot fetch data and store in file based on id in $variable form. For example, $sql="SELECT * FROM mytable WHERE mine_id='1234'"; works for me. But when i use $sql="SELECT * FROM mytable WHERE mine_id='$id'";, files are created as empty. I chanaged the quotes and could not store the data in file. So anyone please help me.
For more clear, i attach the part of my code
for ($i=0;$i<=10;$i++)
{
$id=$seqs[$i];
$dbo = new PDO($dbc, $user, $pass);
echo $sql = "SELECT * FROM mine_id WHERE locus_id='$id'";
$qry = $dbo->prepare($sql);
$qry->execute();
$data = fopen('file.csv', 'w');
while ($row = $qry->fetch(PDO::FETCH_ASSOC))
{
fputcsv($data, $row);
}
}