this is my script, it takes too long , how can I improve the execution time ?
SEE THE ALL OF THE COD: HERE !
$count_nr_attributes = count($nume);
$csv[0] = $csv_array_attributes[0];
for ($i=0; $i < $csv_array_attributes; $i++) {
if ($i > 0){
$final = "";
for ($j=1; $j < $count_nr_attributes; $j++) {
echo "select val_attr from attributes where id_produs = '$csv_array_attributes[$i]' and nume_attr = '$nume[$j]'";echo "<br>";
$select = mysql_query("select val_attr from attributes where id_produs = '$csv_array_attributes[$i]' and nume_attr = '$nume[$j]'");
$count = mysql_num_rows($select);
if ($count == 1){
$row = mysql_fetch_array($select);
$final .= $row['val_attr']."%%";
}else{
$final .= "no%%";
}
}
echo "<hr>";
}
$csv[$i] = $csv_array_attributes[$i]."%%".$final;
}
//create CSV
$file = fopen("attributes.csv","w+");
foreach ($csv as $line){
fputcsv($file,explode('%%',$line),"^","`");
}
The variable $count_nr_attributes contains more then 2500 values and also the $csv_array_attributes contains more then 2500 values. Actually i have two for loops and the execution time takes too long. How can i improve this ? thx
and the query result always return me one value;
mysql_*extension is deprecated, stop using it ASAP. Learn to usemysqli_*and/orPDO6 250 000database queries..