Displaying a progress bar in php file

Course Queries Syllabus Queries 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Syllabus Queries related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago


I have a php file which selects a large amount of data from mutiple sql table. Naturally it takes a long time to complete the whole process. I want to display a progress bar which will express the progress of the script running. How to display a progress bar? The script below shows a portion of the php file.

php

//RIGHT(AdmitCode,1), PartCode, MID(AdmitCode,2,2),  MID(AdmitCode,1,1) DESC, RollCode
$query = "SELECT * FROM students1 ORDER BY PartCode, AdmitCode, yearcode  desc, RollCode";

$result = mysql_query($query);

// start a table tag in the HTML
echo "order='1'  align='center' style='border-collapse:collapse'  width='110%'>"; 
echo "";//$row['index'] the index here is a field name
echo "";

$ty=0;while($row = mysql_fetch_array($result)){//Creates a loop to loop through   results
    $ty++;if($ty%2==0)
        echo "";else
        echo "";
    echo "";}

echo "

List of candidates for Three year Degree (Honours/General) Programme Examination-".$bx1." (".$bx2.")

Sl. No ID Semester Roll No Registration No Name Honours Elective-1 Elective-2 Elective-3 MIL Foundation Soft studies Syllabus
$ty " . $row['StudentID']." " . $row['PartCode']." " . $row['AdmitRollNo'] . " " . $row['RegistrationNo']. " " . $row['Name'] . " " . $row['HonoursSubject'] . " ". $row['ElectiveSubject1'] . " ". $row['ElectiveSubject2'] . " ". $row['ElectiveSubject3'] . " ". $row['MIL'] . " ". $row['Foundation'] . " ". $row['SoftStudies'] . " ". $row['Syllabus'] . "
"
; //Close the table in HTML
profilepic.png
manpreet 2 years ago


You can use the following simple code

    php
    //header('Content-Type: text/event-stream');
    // recommended to prevent caching of event data.
    header('Cache-Control: no-cache'); 

    //long_process.php
    for($i=1;$i<=3;$i++){
        //do something
        echo '
processing...'
; ob_flush(); flush(); sleep(1); } echo 'CLOSE', 'Process complete'; ?>

Or use as following

index.php

    html>
    <html>
       
           charset="utf-8" />
       
       
           />
          <input type="button" onClick="startTask()"  value="Start Long Task" />
          <input type="button" onClick="stopTask();"  value="Stop Task" />
           />
           />
          

Results

/> id="results" style="border:1px solid #000; padding:10px; width:300px; height:250px; overflow:auto; background:#eee;">
/> id='progressor' value="0" max='100' style=""> id="percentage" style="text-align:right; display:block; margin-top:5px;">0 html> type="text/javascript" src="js/jquery.min.js"> type="text/javascript"> var es; function startTask() { es = new EventSource('bar2.php'); //a message is received es.addEventListener('message', function(e) { var result = JSON.parse( e.data ); addLog(result.message); if(e.
0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.