Jump to content

See status on update


znopie

Recommended Posts

Hello all,

 

I'm doing a little code which should be able to check the status of price update. My price update file contains more than 9999999 prices, and I would therefore like that when I appreciate the update starts, then I just Update forward, and when I touch it says it "reads ($instUpdate->instLine+1) lines "

 

Hope you can help  ::)

 

<?php /* START */
    set_time_limit(0);

class instUpdate {
    public $instFile, $instLine=0; // instLine is where to start
    public function start()
    {
        $idfyFile    =    file_get_contents($this->instFile);
        $lineFile    = explode("\n", $idfyFile);
        
        for ($i = $this->instLine; $i < count($lineFile); $i++) {
            $this->instLine++;
            $price['name']    = substr($lineFile[$i], 50,33);
            $price['price']    = substr($lineFile[$i], 42,;
            
            $indhold = trim($price['name']).";".number_format($price['price']/100, 2, ",", ".")." DKK\n";
            $fil = fopen("pris.csv", "a");
            fwrite($fil, $indhold);
            fclose($fil);
        }
    }
}
$instUpdate = new instUpdate(); $instUpdate->instFile = 'pris.txt'; // Pris = Price

if ($_POST['update']) {
     $instUpdate->start();
    echo "<center>Reads: <b>".($instUpdate->instLine+1)."</b> lines<br /><form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\"><input type=\"submit\" name=\"update\" value=\"Update\" style=\"width:115px;padding:2px;\" /></form></center>";
} elseif ($_POST['start']) {
    $instUpdate->start();
    echo "<center><form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\"><input type=\"submit\" name=\"update\" value=\"Update\" style=\"width:115px;padding:2px;\" /></form></center>";
} else {
    echo "<center><form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\"><input type=\"submit\" name=\"start\" value=\"Start price update\" style=\"width:150px;padding:2px;\" /></form></center>";
}    

/* END */ ?> 

Link to comment
https://forums.phpfreaks.com/topic/136071-see-status-on-update/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.