Jump to content

Archived

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

Humpty

PHP progress Bars

Recommended Posts

[b](appologies for 2 posts...was accident)[/b]
G'day again all powerfull PHPers,

I am about to make a very long piece of code, (coz my SQL sucks), that will involve a hand full of loops and a few SELECTs and INSERTs.

I come from a land of VB where if I needed to such things I would have a progress bar or other indication that all is well.

Is there something similar that I can do in PHP?

..so far pages I've done wait till everything is done before the page is dispalyed to the user.

This is trageted at people who I KNOW will think it froze and start clicking and closing impatiently.

Any suggestions?

Share this post


Link to post
Share on other sites
[!--quoteo(post=353522:date=Mar 10 2006, 05:31 AM:name=Humpty)--][div class=\'quotetop\']QUOTE(Humpty @ Mar 10 2006, 05:31 AM) [snapback]353522[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[b](appologies for 2 posts...was accident)[/b]
G'day again all powerfull PHPers,

I am about to make a very long piece of code, (coz my SQL sucks), that will involve a hand full of loops and a few SELECTs and INSERTs.

I come from a land of VB where if I needed to such things I would have a progress bar or other indication that all is well.

Is there something similar that I can do in PHP?

..so far pages I've done wait till everything is done before the page is dispalyed to the user.

This is trageted at people who I KNOW will think it froze and start clicking and closing impatiently.

Any suggestions?
[/quote]

The only way something like this could be done would be using Ajax, I think. however... how about you explain what you want to do and we can help come up with an alternative or a better approach so you dont have such long page rendering time?

Share this post


Link to post
Share on other sites
I try to keep things as short as possible coz I hate reading long Q's myself.

...but here goes:

3 Tables: hardware, hardwareinactive and newhardware.

hardware contains hardware for an online shop
hardwareinactive contains the items that you don't want displayed, (purposely kept to shorten the first talbe, but provide a cross reference for newhardware so I don't update into hardware things I don't want.

newhardware is where I upload my suppliers price list.

I'm gonna write what I want in a SQL / if then / english mix

IF hardware.PartNum and newhardware.PartNum = same THEN
IF hardware.PriceEx1 not= newhardware.PriceEx1 THEN hardware.PriceEx1=newhardware.PriceEx1
IF hardware.Weight=NULL THEN hardware.Weight=newhardware.Weight
IF hardware.URL=NULL THEN hardware.URL=newhardware.URL
IF hardware.Height=NULL THEN hardware.Weight=newhardware.Weight
Delete that row / record from newhardware
ELSE IF hardwareinactive.PartNum and newhardware.PartNum = same THEN
Update Whole Lot into hardwareinactive
Delete that row / record from newhardware
ELSE
newhardware.hasimage='NEWPRODUCT'
END IF

That was as sensical as I could make it.

Sorry :D

Share this post


Link to post
Share on other sites
This is my actual code.

Not tested, should work with exceptin of some errors but gives better idea to all you PHPers. :D

[code]<?
    echo"<BR><BR>This is the Thorough by pass.<BR><BR>";
    $user="USERNAME_CORRECT";
    $password="PASSWORD_CORRECT";
    $database="DATABASENAME_CORRECT";
    
    mysql_connect("localhost",$user,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    //END SECTION:  Connects to database
    


                $query3 = "UPDATE hardware SET hasimage='NOTinNEWlist'";
                $result3=mysql_query($query3) or die ("uhoh; I stuffed up.....sorry UPDATING hardware :(");
                $query3 = "UPDATE hardwareinactive SET hasimage='NOTinNEWlist'";
                $result3=mysql_query($query3) or die ("uhoh; I stuffed up.....sorry DELETING FROM newhardware :(");


    //START SECTION: For Getting Total number of records
    
    
    $query="SELECT * FROM newhardware ORDER BY PartNum";
    
    //$query="SELECT * FROM shoplog ORDER BY VisDate DESC, VisTime DESC LIMIT $startingat, 100";
    $result=mysql_query($query) or die ("uhoh; I stuffed up.....sorry :(");
    $num=mysql_numrows($result);
    echo "$num entries initialy found in newhardware";

    $NumNewProds=0;

    //START SECTION:  The loop for showing results
    $i=0;
    while ($i < $num) {
        //START SUB-SECTION: Display the actual results
        $PartNum=mysql_result($result,$i,"PartNum");
        $PriceEx1=mysql_result($result,$i,"PriceEx1");
        $PriceInc1=mysql_result($result,$i,"PriceInc1");
        $BoxHeight=mysql_result($result,$i,"BoxHeight");
        $BoxWidth=mysql_result($result,$i,"BoxWidth");
        $BoxLength=mysql_result($result,$i,"BoxLength");
        $BoxVolume=mysql_result($result,$i,"BoxVolume");
        $Weight=mysql_result($result,$i,"Weight");
        $Warranty=mysql_result($result,$i,"Warranty");
        $ProductURL=mysql_result($result,$i,"ProductURL");
        $Vendor=mysql_result($result,$i,"Vendor");
        $RRP=mysql_result($result,$i,"RRP");
    
            $query2="SELECT * FROM hardware WHERE PartNum = '$PartNum'";
            $result2=mysql_query($query2) or die ("uhoh; I stuffed up.....sorry :(");
            $num2=mysql_numrows($result2);

            if ($num==0){
                //no results
                $NumNewProds = $NumNewProds+1;
            } elseif($num=1) {
                //Perfect.  Check as required and update what needed
                $PartNum2=mysql_result($result2,0,"PartNum");
                $PriceEx12=mysql_result($result2,0,"PriceEx1");
                $PriceInc12=mysql_result($result2,0,"PriceInc1");
                $BoxHeight2=mysql_result($result2,0,"BoxHeight");
                $BoxWidth2=mysql_result($result2,0,"BoxWidth");
                $BoxLength2=mysql_result($result2,0,"BoxLength");
                $BoxVolume2=mysql_result($result2,0,"BoxVolume");
                $Weight2=mysql_result($result2,0,"Weight");
                $Warranty2=mysql_result($result2,0,"Warranty");
                $ProductURL2=mysql_result($result2,0,"ProductURL");
                $Vendor2=mysql_result($result2,0,"Vendor");
                $RRP2=mysql_result($result2,0,"RRP");
                $myString2 = "";
                //Check Price diff
                if ($PriceEx1 != $PriceEx){
                     $myString2="hasimage='PRICESAME'";
                } else {
                     $myString2="hasimage='PRICECHANGE'";
                }
                //Check BoxHeight
                if ($BoxHeight2 == "" OR $BoxHeight2 IS NULL){ $myString2 = $myString2 . ", BoxHeight='$BoxHeight'"; }
                //Check BoxWidth
                if ($BoxWidth2 == "" OR $BoxWidth2 IS NULL){ $myString2 = $myString2 . ", BoxWidth='$BoxWidth'"; }
                //Check BoxLength
                if ($BoxLength2 == "" OR $BoxLength2 IS NULL){ $myString2 = $myString2 . ", BoxLength='$BoxLength'"; }
                //Check BoxVolume
                if ($BoxVolume2 == "" OR $BoxVolume2 IS NULL){ $myString2 = $myString2 . ", BoxVolume='$BoxVolume'"; }
                //Check Weight
                if ($Weight2 == "" OR $Weight2 IS NULL){ $myString2 = $myString2 . ", Weight='$Weight'"; }
                //Check Warranty
                if ($Warranty2 == "" OR $Warranty2 IS NULL){ $myString2 = $myString2 . ", Warranty='$Warranty'"; }
                //Check ProductURL
                if ($ProductURL2 == "" OR $ProductURL2 IS NULL){ $myString2 = $myString2 . ", ProductURL='$ProductURL'"; }
                //Check Vendor
                if ($Vendor2 == "" OR $Vendor2 IS NULL){ $myString2 = $myString2 . ", Vendor='$Vendor'"; }
                //Check Weight
                if ($RRP2 == "" OR $RRP2 IS NULL){ $myString2 = $myString2 . ", RRP='$RRP'"; }

                //make string
                $query3 = "UPDATE hardware SET " . $myString3  . " WHERE PartNum=$PartNum";
                $result3=mysql_query($query3) or die ("uhoh; I stuffed up.....sorry UPDATING hardware :(");
                $query3 = "DELTE FROM newhardware WHERE PartNum=$PartNum";
                $result3=mysql_query($query3) or die ("uhoh; I stuffed up.....sorry DELETING FROM newhardware :(");

            } elseif($num=1) {
                //There is a double up in hardware
                echo"<BR>Table hardware contains a double up of the following Part#: $PartNum<BR><BR>";
            }



//This is the firstLoop
    $i++;
    }


//#########################################
//#########################################
// THIS IS FOR THE hardwareinactive table:
//#########################################
//#########################################

    mysql_connect("localhost",$user,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    //END SECTION:  Connects to database
    
    //START SECTION: For Getting Total number of records
    
    
    $query="SELECT * FROM newhardware ORDER BY PartNum";
    
    //$query="SELECT * FROM shoplog ORDER BY VisDate DESC, VisTime DESC LIMIT $startingat, 100";
    $result=mysql_query($query) or die ("uhoh; I stuffed up.....sorry :(");
    $num=mysql_numrows($result);
    echo "$num entries left in newhardware after updating hardware";

    //START SECTION:  The loop for showing results
    $i=0;
    while ($i < $num) {
        //START SUB-SECTION: Display the actual results
        $PartNum=mysql_result($result,$i,"PartNum");
        $PriceEx1=mysql_result($result,$i,"PriceEx1");
        $PriceInc1=mysql_result($result,$i,"PriceInc1");
        $BoxHeight=mysql_result($result,$i,"BoxHeight");
        $BoxWidth=mysql_result($result,$i,"BoxWidth");
        $BoxLength=mysql_result($result,$i,"BoxLength");
        $BoxVolume=mysql_result($result,$i,"BoxVolume");
        $Weight=mysql_result($result,$i,"Weight");
        $Warranty=mysql_result($result,$i,"Warranty");
        $ProductURL=mysql_result($result,$i,"ProductURL");
        $Vendor=mysql_result($result,$i,"Vendor");
        $RRP=mysql_result($result,$i,"RRP");
    
            $query2="SELECT * FROM hardwareinactive WHERE PartNum = '$PartNum'";
            $result2=mysql_query($query2) or die ("uhoh; I stuffed up.....sorry KILLED CODE FOR inactive hardware :(");
            $num2=mysql_numrows($result2);

            if ($num==0){
                //no results
            } elseif($num=1) {
                //Perfect.  Check as required and update what needed
                $PartNum2=mysql_result($result2,0,"PartNum");
                $PriceEx12=mysql_result($result2,0,"PriceEx1");
                $PriceInc12=mysql_result($result2,0,"PriceInc1");
                $BoxHeight2=mysql_result($result2,0,"BoxHeight");
                $BoxWidth2=mysql_result($result2,0,"BoxWidth");
                $BoxLength2=mysql_result($result2,0,"BoxLength");
                $BoxVolume2=mysql_result($result2,0,"BoxVolume");
                $Weight2=mysql_result($result2,0,"Weight");
                $Warranty2=mysql_result($result2,0,"Warranty");
                $ProductURL2=mysql_result($result2,0,"ProductURL");
                $Vendor2=mysql_result($result2,0,"Vendor");
                $RRP2=mysql_result($result2,0,"RRP");
                $myString2 = "";
                //Check Price diff
                if ($PriceEx1 != $PriceEx){
                     $myString2="hasimage='PRICESAME'";
                } else {
                     $myString2="hasimage='PRICECHANGE'";
                }
                //Check BoxHeight
                if ($BoxHeight2 == "" OR $BoxHeight2 IS NULL){ $myString2 = $myString2 . ", BoxHeight='$BoxHeight'"; }
                //Check BoxWidth
                if ($BoxWidth2 == "" OR $BoxWidth2 IS NULL){ $myString2 = $myString2 . ", BoxWidth='$BoxWidth'"; }
                //Check BoxLength
                if ($BoxLength2 == "" OR $BoxLength2 IS NULL){ $myString2 = $myString2 . ", BoxLength='$BoxLength'"; }
                //Check BoxVolume
                if ($BoxVolume2 == "" OR $BoxVolume2 IS NULL){ $myString2 = $myString2 . ", BoxVolume='$BoxVolume'"; }
                //Check Weight
                if ($Weight2 == "" OR $Weight2 IS NULL){ $myString2 = $myString2 . ", Weight='$Weight'"; }
                //Check Warranty
                if ($Warranty2 == "" OR $Warranty2 IS NULL){ $myString2 = $myString2 . ", Warranty='$Warranty'"; }
                //Check ProductURL
                if ($ProductURL2 == "" OR $ProductURL2 IS NULL){ $myString2 = $myString2 . ", ProductURL='$ProductURL'"; }
                //Check Vendor
                if ($Vendor2 == "" OR $Vendor2 IS NULL){ $myString2 = $myString2 . ", Vendor='$Vendor'"; }
                //Check Weight
                if ($RRP2 == "" OR $RRP2 IS NULL){ $myString2 = $myString2 . ", RRP='$RRP'"; }

                //make string
                $query3 = "UPDATE hardwareinactive SET " . $myString3  . " WHERE PartNum=$PartNum";
                $result3=mysql_query($query3) or die ("uhoh; I stuffed up.....sorry UPDATING hardwareinactive :(");
                $query3 = "DELTE FROM newhardware WHERE PartNum=$PartNum";
                $result3=mysql_query($query3) or die ("uhoh; I stuffed up.....sorry DELETING FROM newhardware :(");
                $NumNewProds = $NumNewProds-1;

            } elseif($num=1) {
                //There is a double up in hardware
                echo"<BR>Table hardware contains a double up of the following Part#: $PartNum<BR><BR>";
            }



//This is the firstLoop
    $i++;
    }


echo "<BR><BR><BR> There are $NumNewProds new products to check in new hardware.<BR><BR>Don't forget to check hardware and inactive hardware for Price Changes and adjust mark up accordingly<BR>Don't forget to check Hardware and Hardware Inactive for items that are no longer offered by supplier to remove them"

?>[/code]

Share this post


Link to post
Share on other sites
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]IF hardware.PartNum and newhardware.PartNum = same THEN
IF hardware.PriceEx1 not= newhardware.PriceEx1 THEN hardware.PriceEx1=newhardware.PriceEx1
IF hardware.Weight=NULL THEN hardware.Weight=newhardware.Weight
IF hardware.URL=NULL THEN hardware.URL=newhardware.URL
IF hardware.Height=NULL THEN hardware.Weight=newhardware.Weight
Delete that row / record from newhardware
ELSE IF hardwareinactive.PartNum and newhardware.PartNum = same THEN
Update Whole Lot into hardwareinactive
Delete that row / record from newhardware
ELSE
newhardware.hasimage='NEWPRODUCT'
END IF [/quote]

That's known as Pseudo-Code..

The flaw in this design, is the design of your SQL statements.

I would have laid your database out in a very different way, I think..

Think of a database like this. All parts, 1 table, with different statusid's ( relational to the status table where you can expand different status id's and track what they mean ).. Think status 10 = new parts, status 200 = hidden hardware..

so for new parts, in a theoretical table you could say..

[code]select * from hardware where statusid = 10[/code]

I hope this steers you in a good direction.

Share this post


Link to post
Share on other sites
I thought about the whole status idea thing but i didn't want a table that was gonna be bloated. I wanted faster results when people view the products. However although I couldn't forsee me having that many products it would matter, other people will use this. Some people I am giving this complete shop and code to, other people are going to buy it with combintion of VB written software that integrates a common IT stock / sales managment program with the online shop. The qty of products these people have i don't know.

This is what I ended up with and it actually works very well, (sure it could be faster if I re-arranged the DB, thus needing less code for this part of it, but i'd rather the end user of the shop get quicker results if it were a bloated table.

[code]<?
                // ERROR TRAPING / DEBUGING
                // (swap between these following 2 lines)
                        error_reporting(E_ALL);
                //        error_reporting(0);

    echo"<BR><BR>Initiating The Transfers.<BR><BR>";
    $user="CORRECT";
    $password="CORRECT";
    $database="CORRECT";
    
    mysql_connect("localhost",$user,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    

                $query3 = "UPDATE hardware SET hasimage='NOTinNEWlist'";
                $result3=mysql_query($query3) or die ("uhoh; I stuffed up.....sorry NOTinNEWlist hardware :(");
                $query3 = "UPDATE hardwareinactive SET hasimage='NOTinNEWlist'";
                $result3=mysql_query($query3) or die ("uhoh; I stuffed up.....sorry NOTinNEWlist hardwareinactive :(");
echo "<BR>hardware and hardwareinactive entries are now ALL flagged as NOTinNEWlist<BR>";


    //START SECTION: For Getting Total number of records
    

    $query="SELECT * FROM newhardware ORDER BY Partnum";
    //$query="SELECT * FROM shoplog ORDER BY VisDate DESC, VisTime DESC LIMIT $startingat, 100";

    $result=mysql_query($query) or die ("uhoh; I stuffed up.....sorry :(");
    $num=mysql_numrows($result);
    echo "<BR>number of entries in newhardware = $num <BR>";
    mysql_close();
    $numNewProds=0;

    //START SECTION:  The loop for showing results

    $i=0;
Echo"<BR><BR><BR><B>NOTE:</B> you should see dots appearing below here while this is in progress<BR>You will also see any required messages.<BR>";
    while ($i < $num) {
?>.<?
        //START SUB-SECTION: Display the actual results
        $Partnum=mysql_result($result,$i,"Partnum");
        $PriceEx1=mysql_result($result,$i,"PriceEx1");
        $PriceInc1=mysql_result($result,$i,"PriceInc1");
        $BoxHeight=mysql_result($result,$i,"BoxHeight");
        $BoxWidth=mysql_result($result,$i,"BoxWidth");
        $BoxLength=mysql_result($result,$i,"BoxLength");
        $BoxVolume=mysql_result($result,$i,"BoxVolume");
        $Weight=mysql_result($result,$i,"Weight");
        $Warranty=mysql_result($result,$i,"Warranty");
        $ProductURL=mysql_result($result,$i,"ProductURL");
        $Vendor=mysql_result($result,$i,"Vendor");
        $RRP=mysql_result($result,$i,"RRP");

            mysql_connect("localhost",$user,$password);
            @mysql_select_db($database) or die( "Unable to select database");
            $query2="SELECT * FROM hardware WHERE Partnum = '$Partnum'";
            $result2=mysql_query($query2) or die ("uhoh; I stuffed up.....sorry :(");
            $num2=mysql_numrows($result2);
            mysql_close();
            if ($num2==0){
                //no results
mysql_connect("localhost",$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query5="SELECT * FROM hardwareinactive WHERE Partnum = '$Partnum'";
$result5=mysql_query($query5) or die ("uhoh; I stuffed up.....sorry This was done while checking inactive hardware:(");
$num5=mysql_numrows($result5);
mysql_close();
if ($num5==0){
    //no results
} elseif($num5=1) {
    //Perfect.  Check as required and update what needed
    $Partnum5=mysql_result($result5,0,"Partnum");
    $PriceEx15=mysql_result($result5,0,"PriceEx1");
    $PriceInc15=mysql_result($result5,0,"PriceInc1");
    $BoxHeight5=mysql_result($result5,0,"BoxHeight");
    $BoxWidth5=mysql_result($result5,0,"BoxWidth");
    $BoxLength5=mysql_result($result5,0,"BoxLength");
    $BoxVolume5=mysql_result($result5,0,"BoxVolume");
    $Weight5=mysql_result($result5,0,"Weight");
    $Warranty5=mysql_result($result5,0,"Warranty");
    $ProductURL5=mysql_result($result5,0,"ProductURL");
    $Vendor5=mysql_result($result5,0,"Vendor");
    $RRP5=mysql_result($result5,0,"RRP");
    $myString5 = "";
    //Check Price diff
    if ($PriceEx15 != $PriceEx1){
         $myString5="hasimage='PRICESAME'";
    } else {
         $myString5="hasimage='PRICECHANGE'";
    }
    //Check BoxHeight
    if ($BoxHeight5 == "" OR $BoxHeight5 == NULL){ $myString5 = $myString5 . ", BoxHeight='$BoxHeight'"; }
    //Check BoxWidth
    if ($BoxWidth5 == "" OR $BoxWidth5 == NULL){ $myString5 = $myString5 . ", BoxWidth='$BoxWidth'"; }
    //Check BoxLength
    if ($BoxLength5 == "" OR $BoxLength5 == NULL){ $myString5 = $myString5 . ", BoxLength='$BoxLength'"; }
    //Check BoxVolume
    if ($BoxVolume5 == "" OR $BoxVolume5 == NULL){ $myString5 = $myString5 . ", BoxVolume='$BoxVolume'"; }
    //Check Weight
    if ($Weight5 == "" OR $Weight5 == NULL){ $myString5 = $myString5 . ", Weight='$Weight'"; }
    //Check Warranty
    if ($Warranty5 == "" OR $Warranty5 == NULL){ $myString5 = $myString5 . ", Warranty='$Warranty'"; }
    //Check ProductURL
    if ($ProductURL5 == "" OR $ProductURL5 == NULL){ $myString5 = $myString5 . ", ProductURL='$ProductURL'"; }
    //Check Vendor
    if ($Vendor5 == "" OR $Vendor5 == NULL){ $myString5 = $myString5 . ", Vendor='$Vendor'"; }
    //Check Weight
    if ($RRP5 == "" OR $RRP5 == NULL){ $myString5 = $myString5 . ", RRP='$RRP'"; }

    mysql_connect("localhost",$user,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    //make string
    $query6 = "UPDATE hardwareinactive SET " . $myString5  . " WHERE Partnum='$Partnum'";
    $result6=mysql_query($query6) or die ("uhoh; I stuffed up.....sorry UPDATING hardwareinactive :(<BR><BR> $query3<BR>");
    $query6 = "DELETE FROM newhardware WHERE Partnum='$Partnum'";
    $result6=mysql_query($query6) or die ("uhoh; I stuffed up.....sorry DELETING FROM newhardware (during hardware run) :(");
mysql_close();

} elseif($num5=1) {
    //There is a double up in hardware
    echo"<BR>$Partnum is a double entry in hardwareinactive <BR><BR>";
}


            } elseif($num2=1) {
                //Perfect.  Check as required and update what needed
                $Partnum2=mysql_result($result2,0,"Partnum");
                $PriceEx12=mysql_result($result2,0,"PriceEx1");
                $PriceInc12=mysql_result($result2,0,"PriceInc1");
                $BoxHeight2=mysql_result($result2,0,"BoxHeight");
                $BoxWidth2=mysql_result($result2,0,"BoxWidth");
                $BoxLength2=mysql_result($result2,0,"BoxLength");
                $BoxVolume2=mysql_result($result2,0,"BoxVolume");
                $Weight2=mysql_result($result2,0,"Weight");
                $Warranty2=mysql_result($result2,0,"Warranty");
                $ProductURL2=mysql_result($result2,0,"ProductURL");
                $Vendor2=mysql_result($result2,0,"Vendor");
                $RRP2=mysql_result($result2,0,"RRP");
                $myString2 = "";
                //Check Price diff
                if ($PriceEx12 != $PriceEx1){
                     $myString2="hasimage='PRICESAME'";
                } else {
                     $myString2="hasimage='PRICECHANGE'";
                }
                //Check BoxHeight
                if ($BoxHeight2 == "" OR $BoxHeight2 == NULL){ $myString2 = $myString2 . ", BoxHeight='$BoxHeight'"; }
                //Check BoxWidth
                if ($BoxWidth2 == "" OR $BoxWidth2 == NULL){ $myString2 = $myString2 . ", BoxWidth='$BoxWidth'"; }
                //Check BoxLength
                if ($BoxLength2 == "" OR $BoxLength2 == NULL){ $myString2 = $myString2 . ", BoxLength='$BoxLength'"; }
                //Check BoxVolume
                if ($BoxVolume2 == "" OR $BoxVolume2 == NULL){ $myString2 = $myString2 . ", BoxVolume='$BoxVolume'"; }
                //Check Weight
                if ($Weight2 == "" OR $Weight2 == NULL){ $myString2 = $myString2 . ", Weight='$Weight'"; }
                //Check Warranty
                if ($Warranty2 == "" OR $Warranty2 == NULL){ $myString2 = $myString2 . ", Warranty='$Warranty'"; }
                //Check ProductURL
                if ($ProductURL2 == "" OR $ProductURL2 == NULL){ $myString2 = $myString2 . ", ProductURL='$ProductURL'"; }
                //Check Vendor
                if ($Vendor2 == "" OR $Vendor2 == NULL){ $myString2 = $myString2 . ", Vendor='$Vendor'"; }
                //Check Weight
                if ($RRP2 == "" OR $RRP2 == NULL){ $myString2 = $myString2 . ", RRP='$RRP'"; }

                mysql_connect("localhost",$user,$password);
                @mysql_select_db($database) or die( "Unable to select database");

                //make string
                $query3 = "UPDATE hardware SET " . $myString2  . " WHERE Partnum='$Partnum'";
                $result3=mysql_query($query3) or die ("uhoh; I stuffed up.....sorry UPDATING hardware :(<BR><BR> $query3<BR>");
                $query3 = "DELETE FROM newhardware WHERE Partnum='$Partnum'";
                $result3=mysql_query($query3) or die ("uhoh; I stuffed up.....sorry DELETING FROM newhardware (during hardware run) :(");
    mysql_close();

            } elseif($num2=1) {
                //There is a double up in hardware
                echo"<BR>$Partnum is a double entry in hardware<BR><BR>";
            }

//This is the firstLoop
    $i++;
    }
echo "<BR>END OF LOOP<BR>";



    mysql_connect("localhost",$user,$password);
    @mysql_select_db($database) or die( "Unable to select database");

echo"<BR><BR><BR><B>THE OUTCOME:</B><BR>";

//New Hardware
    $query="SELECT * FROM newhardware";
    $result=mysql_query($query) or die ("uhoh; I stuffed up.....sorry :(");
    $nNewProds=mysql_numrows($result);
echo"<BR>$nNewProds New Products - Please ensure that you check these and add them to the correct table.<BR>";

//Hardware
    $query="SELECT * FROM hardware WHERE hasimage = 'PRICESAME'";
    $result=mysql_query($query) or die ("uhoh; I stuffed up.....sorry :(");
    $nSamePrice=mysql_numrows($result);
echo"<BR>$nSamePrice Products updated but price is the same.<BR>";

    $query="SELECT * FROM hardware WHERE hasimage = 'PRICECHANGE'";
    $result=mysql_query($query) or die ("uhoh; I stuffed up.....sorry :(");
    $nPriceChange=mysql_numrows($result);
echo"<BR>$nPriceChange Products had a price change - Please review these products and alter your sale price accordingly<BR>";

    $query="SELECT * FROM hardware WHERE hasimage = 'NOTinNEWlist'";
    $result=mysql_query($query) or die ("uhoh; I stuffed up.....sorry :(");
    $nNOTinNEWlist=mysql_numrows($result);
echo"<BR>$nNOTinNEWlist Products which were not in the list of updated details - Please review these products and remove them if they are no longer going to be supplied<BR>";

//Hardware Inactive
    $query="SELECT * FROM hardwareinactive WHERE hasimage = 'PRICESAME'";
    $result=mysql_query($query) or die ("uhoh; I stuffed up.....sorry :(");
    $nSamePrice=mysql_numrows($result);
echo"<BR>$nSamePrice Inactive Products updated but price is the same.<BR>";

    $query="SELECT * FROM hardwareinactive WHERE hasimage = 'PRICECHANGE'";
    $result=mysql_query($query) or die ("uhoh; I stuffed up.....sorry :(");
    $nPriceChange=mysql_numrows($result);
echo"<BR>$nPriceChange Inactive Products had a price change - Please review these products and alter your sale price accordingly<BR>";

    $query="SELECT * FROM hardwareinactive WHERE hasimage = 'NOTinNEWlist'";
    $result=mysql_query($query) or die ("uhoh; I stuffed up.....sorry :(");
    $nNOTinNEWlist=mysql_numrows($result);
echo"<BR>$nNOTinNEWlist Inactive Products which were not in the list of updated details - Please review these products and remove them if they are no longer going to be supplied<BR>";


?>[/code]

Messy yes, functional yes. Happy, yes, could imporove on yes, but not going to.

Thanks for your help. Have bookmarked the page for your reply if i feel I need to change it in the future. No i'm 1 step closer to being completed. - Thankyou

Share this post


Link to post
Share on other sites

×

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.