Page 1 of 1
Multiple queries in a PHP page
Posted: Tue Nov 22, 2011 8:40 am
by markniazi
I have 20 mysql queries in a PHP page, browser displays the output when all queries are processed, it takes about 1 minute.
Is there any way that results are shown one by one, I mean, first query is processed and results are displayed, then 2nd query is processed and results are displayed on the same page and so on.
Kindly suggest a solution.
Re: Multiple queries in a PHP page
Posted: Tue Nov 22, 2011 8:55 am
by Celauran
You could have query, then display results, then next query, then display those results, etc. I'd be far more concerned about why you have 20 queries and why they're taking so long.
Re: Multiple queries in a PHP page
Posted: Tue Nov 22, 2011 9:01 am
by maxx99
Something like this could do the trick. But its not a good solution
Code: Select all
for($i=0;$i<10;$i++){
echo "x";//query result
sleep(1);
myflush();
}
function myflush (){
echo(str_repeat(' ',256));
// check that buffer is actually set before flushing
if (ob_get_length()){
@ob_flush();
@flush();
@ob_end_flush();
}
@ob_start();
}
You can always do SYNC AJAX requests client side

Re: Multiple queries in a PHP page
Posted: Tue Nov 22, 2011 9:03 am
by markniazi
Well Celarun, its an assignment, in which I have to manage 20 to 30 queries inside a PHP page
Re: Multiple queries in a PHP page
Posted: Tue Nov 22, 2011 2:53 pm
by califdon
I have the same concern as Celauran. You say that it is an 'assignment'? Like a school assignment? If that is the case, you would need to tell us exactly what the assignment asked you (not us) to do, word for word. And we would need to know what specific programming areas your lectures and reading have covered. As a retired college instructor, I know that just asking someone to give you a solution won't work. The instructor is trying to get a specific answer based on what your previous and current reading and lectures are attempting to teach you. Something that I might suggest to you is likely to not be the answer the instructor is looking for at this point in your studies.