Multiple Querys problem

Hi!
i hope someone have some tips how i can code for this beacuse it take to long time so it only print a blank page

i have about 500 querys like this:


// Affärssystem
$query = "SELECT projektnr, COUNT(foretag) FROM intervjuer WHERE  $leadsfraga1429 like '$utslagsfraga1429' OR ( $leadsfraga14291 like '$utslagsfraga1429' ) OR ( $leadsfraga14292 like '$utslagsfraga1429' ) GROUP BY projektnr DESC limit 1";      
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
    echo "". $row['projektnr'] ." Affärsystem ". $row['COUNT(foretag)'] ." ";
    echo "<br />";
}
// Arbetsbord
$query = "SELECT projektnr, COUNT(foretag) FROM intervjuer WHERE  $leadsfraga1034 like '$utslagsfraga1034' GROUP BY projektnr DESC limit 1";      
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
    echo "". $row['projektnr'] ." Arbetsbord ". $row['COUNT(foretag)'] ." ";
    echo "<br />";
}
// Arbetsmiljöutbildning
$query = "SELECT projektnr, COUNT(foretag) FROM intervjuer WHERE $leadsfraga1446 like '$utslagsfraga1446' GROUP BY projektnr DESC limit 1";      
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
    echo "". $row['projektnr'] ." Arbetsmiljöutbildning  ". $row['COUNT(foretag)'] ." ";
    echo "<br />";
}

Is there a better way to print out this ( notice that every query has a specific name like ( echo “”. $row[‘projektnr’] ." Arbetsmiljöutbildning “. $row[‘COUNT(foretag)’] .” "; ) so i need to get the same results but faster

Hope you guys understand what i mean :slight_smile:

/Tony

Its hard to tell exactly what you are doing here, but it does look very inefficient. The queries and outputs look very similar.
It seems like there should be some way to do this with one query. In your output, only the middle word is different. Could that be stored in the database?
Finding some method that is more flexible and doesn’t rely on so much one off processes is the key.

In every query it´s a different search for results then i print out the answers for each different question
the problem is that i need to control what the outpost are like echo “”. $row[‘projektnr’] ." Arbetsmiljöutbildning “. $row[‘COUNT(foretag)’] .” ";
that means that the search of " Arbetsmiljöutbildning " is outprinted from the database where the question and search parameter i correct ( SELECT projektnr, COUNT(foretag) FROM intervjuer WHERE $leadsfraga1446 like ‘$utslagsfraga1446’ GROUP BY projektnr DESC limit 1 ) and only shows the last “projektnr” stored in the database

No, i cant store the names in the database