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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.