Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Please help me mod this import code! :)

    this is the feed import code from my script. I am going to attempt to add another field which will be 'extra field F'

    can I just add the extra code underneath each instance of 'extra field E' then add the column in the database, will that work?

    (Can't paste the code here as it is too long!)

    http://affilistore-templates.com/atmnt/fd.txt

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts
    Hi,

    Welcome to CF...

    You might have trouble getting anyone to help you with this just because your code is so long... I would recommend isolating the part of your code that is directly related to adding the fields... show us too much code and we get bored/distracted If we need more code we will always ask for it.

    Cheers,

  • #3
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi, thanks for the tip

    I'll post each instance of 'field e' here, want to basically create an extra import field 'F'

    (sorry for the long bits of code! )

    PHP Code:
    // while loop with fgetcsv sorts the csv into the data array 
    while (($data fgetcsv($handle3000$typeFeed)) !== FALSE) {

        
    $resulta $merchantData;
        if (
    $data[intval($_POST['merchantProdIDData'])] == NULL) {
        
    $resultb $row;
        } else {
        
    $resultb $data[intval($_POST['merchantProdIDData'])];
        }
        
    $resultc ucwords(strtolower($data[intval($_POST['prodCategoryData'])]));
        
    $resultd ucwords(strtolower($data[intval($_POST['prodNameData'])]));
        
    $resulte ucwords(strtolower($data[intval($_POST['prodBrandData'])]));
        
    $resultf $data[intval($_POST['prodDescriptionData'])];
        
    $resultg $data[intval($_POST['prodPromoTextData'])];
        
    $resulth $data[intval($_POST['prodLinkData'])];
        
    $resulti $data[intval($_POST['prodImageURLData'])];
        
    $resultj $data[intval($_POST['prodPriceData'])];
        
    $resultk $_POST['prodCurrencyData'];
        
    $resultm $data[intval($_POST['extraFieldAData'])];
        
    $resultn $data[intval($_POST['extraFieldBData'])];
        
    $resulto $data[intval($_POST['extraFieldCData'])];
        
    $resultp $data[intval($_POST['extraFieldDData'])];
        
    $resultq $data[intval($_POST['extraFieldEData'])];
        
    $resultr $data[intval($_POST['prodImageSmallData'])];
        
    $results intval($row);
        
        if (
    $_POST['UrlPrefix'] == 'before'){
        
    $resulth $_POST['UrlPrefixText'].$resulth;
        } else if (
    $_POST['UrlPrefix'] == 'after') {
        
    $resulth $resulth.$_POST['UrlPrefixText'];
        } 
    PHP Code:
    // miss out headers row
       
    if ($row != 0) {
       
    // insert all the data into the database table
            
    $sql sprintf("INSERT INTO affiliSt_products1 (
          
                      merchant,
                    merchantProdID, 
                    prodCategory,
                    prodName,
                    prodBrand,
                    prodDescription,
                    prodPromoText,
                    prodLink, 
                    prodImageURL,
                    prodPrice,
                    prodCurrency,
                    prodDB,
                    extraFieldA,
                    extraFieldB,
                    extraFieldC,
                    extraFieldD,
                    extraFieldE, 
                    prodImageSmall, 
                    dbProdID
                    
                    ) VALUES (
                    
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s
                    )"
    ,
                    
    quote_smart($resulta),
                    
    quote_smart($resultb),
                    
    quote_smart($resultc),
                    
    quote_smart($resultd),
                    
    quote_smart($resulte),
                    
    quote_smart($resultf),
                    
    quote_smart($resultg),
                    
    quote_smart($resulth),
                    
    quote_smart($resulti),
                    
    quote_smart($resultj),
                    
    quote_smart($resultk),
                    
    quote_smart($resultl),
                    
    quote_smart($resultm),
                    
    quote_smart($resultn),
                    
    quote_smart($resulto),
                    
    quote_smart($resultp),
                    
    quote_smart($resultq),
                    
    quote_smart($resultr),
                    
    quote_smart($results));
            
    mysql_query($sql$databaseConnect) or die(mysql_error());
        }
        
        
    $row++;


    PHP Code:
    // move image file to folder on server
    $logoSource $_FILES['logoUpload']['tmp_name'];
        if (
    $logoSource != NULL) {
        
    $logoTarget "userfiles/".$_FILES['logoUpload']['name'];
        
    move_uploaded_file($logoSource'../'.$logoTarget) or die ("couldn't copy");
        } else {
        
    $logoTarget '';
        }


    $insert = array (
            array ( 
    'name' =>  'feedMemory'.($theProdDetails['prodDB'] + 1),
                    
    'value' => $merchantData.'-:-'.intval($merchantProdIDData).'-:-'.intval($prodCategoryData).'-:-'.intval($prodNameData).'-:-'.intval($prodBrandData).'-:-'.intval($prodDescriptionData).'-:-'.intval($prodPromoTextData).'-:-'.intval($prodLinkData).'-:-'.intval($prodImageURLData).'-:-'.intval($prodPriceData).'-:-'.$prodCurrencyData.'-:-'.$_POST['firstRow'].'-:-'.$_POST['UrlPrefix'].'-:-'.$_POST['UrlPrefixText'].'-:-'.intval($extraFieldAData).'-:-'.intval($extraFieldBData).'-:-'.intval($extraFieldCData).'-:-'.intval($extraFieldDData).'-:-'.intval($extraFieldEData).'-:-'.$merchantProdIDTitle.'-:-'.$prodCategoryTitle.'-:-'.$prodNameTitle.'-:-'.$prodBrandTitle.'-:-'.$prodDescriptionTitle.'-:-'.$prodPromoTextTitle.'-:-'.$prodLinkTitle.'-:-'.$prodImageURLTitle.'-:-'.$prodPriceTitle.'-:-'.$extraFieldATitle.'-:-'.$extraFieldBTitle.'-:-'.$extraFieldCTitle.'-:-'.$extraFieldDTitle.'-:-'.$extraFieldETitle.'-:-'.$logoTarget.'-:-'.intval($prodImageSmallData),
                    
    'comment' => 'Remembers which feed columns have been put into AffiliStore columns',
                    
    'title' => 'Feed Memory'),
            array ( 
    'name' =>  'csvURL'.($theProdDetails['prodDB'] + 1),
                    
    'value' => $handle,
                    
    'comment' => 'The link to your product feed',
                    
    'title' => $whichFeed),
            array ( 
    'name' =>  'csvType'.($theProdDetails['prodDB'] + 1),
                    
    'value' => $_POST['typeFeed'],
                    
    'comment' => 'The format of the product field eg. comma seperated, xml etc.',
                    
    'title' => 'Product Feed Type'),
            array ( 
    'name' =>  'nav'.($theProdDetails['prodDB'] + 1),
                    
    'value' => $newnavigation,
                    
    'comment' => 'Category and subcategory navigation',
                    
    'title' => 'Generated Navigation'),
            array ( 
    'name' =>  'compression'.($theProdDetails['prodDB'] + 1),
                    
    'value' => $_POST['compressionType'],
                    
    'comment' => 'Type of compression used for feed',
                    
    'title' => 'Compression Type')
    );
        
        
    // insert values posted from Step 1 into config table
    foreach ($insert as $row) {
        
    $sql sprintf("INSERT INTO affiliSt_config (
                name, value, comment, title
                ) values (
                %s, %s, %s, %s
                )"
    ,
                
    quote_smart($row['name']),
                
    quote_smart($row['value']),
                
    quote_smart($row['comment']),
                
    quote_smart($row['title']));
        
    mysql_query($sql$databaseConnect) or die(mysql_error());

    PHP Code:
    // miss out headers row
       
    if ($row != 0) {
       
    // insert all the data into the database table
            
    $sql sprintf("INSERT INTO affiliSt_products1 (
          
                      merchant,    
                    merchantProdID,     
                    prodCategory,    
                    prodName,     
                    prodBrand,     
                    prodDescription,     
                    prodPromoText,     
                    prodLink,     
                    prodImageURL,     
                    prodPrice, 
                    prodCurrency,
                    prodDB,
                    extraFieldA,
                    extraFieldB,
                    extraFieldC,
                    extraFieldD,
                    extraFieldE,     
                    prodImageSmall,     
                    dbProdID
                    
                    ) VALUES (
                    
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s,
                    %s
                    )"
    ,
                    
    quote_smart($resulta),
                    
    quote_smart($resultb),
                    
    quote_smart($resultc),
                    
    quote_smart($resultd),
                    
    quote_smart($resulte),
                    
    quote_smart($resultf),
                    
    quote_smart($resultg),
                    
    quote_smart($resulth),
                    
    quote_smart($resulti),
                    
    quote_smart($resultj),
                    
    quote_smart($resultk),
                    
    quote_smart($resultl),
                    
    quote_smart($resultm),
                    
    quote_smart($resultn),
                    
    quote_smart($resulto),
                    
    quote_smart($resultp),
                    
    quote_smart($resultq),
                    
    quote_smart($resultr),
                    
    quote_smart($results));
            
    mysql_query($sql$databaseConnect) or die(mysql_error());
        }
        
        
    $row++;


    PHP Code:
    //Get names of columns in table
    $field_names = array('merchant''merchantProdID''prodCategory''prodName''prodBrand''prodDescription''prodPromoText''prodLink''prodImageURL''prodImageSmall''extraFieldA''extraFieldB''extraFieldC''extraFieldD''extraFieldE''prodPrice');

    $totalCols count($field_names);
             for (
    $ab=0$ab $totalCols$ab++) {
                
            if (
    $field_names[$ab] == 'merchant') {
            
    $ascolname 'Merchant Name';
            } else if (
    $field_names[$ab] == 'merchantProdID') {
            
    $ascolname 'Merchant Product ID';
            } else if (
    $field_names[$ab] == 'prodCategory') {
            
    $ascolname 'Product Category';
            } else if (
    $field_names[$ab] == 'prodName') {
            
    $ascolname 'Product Name';
            } else if (
    $field_names[$ab] == 'prodBrand') {
            
    $ascolname 'Product Brand';
            } else if (
    $field_names[$ab] == 'prodDescription') {
            
    $ascolname 'Product Description';
            } else if (
    $field_names[$ab] == 'prodPromoText') {
            
    $ascolname 'Promotional Text';
            } else if (
    $field_names[$ab] == 'prodLink') {
            
    $ascolname 'Affiliate Product Link';
            } else if (
    $field_names[$ab] == 'prodImageURL') {
            
    $ascolname 'Product Image URL';
            } else if (
    $field_names[$ab] == 'prodImageSmall') {
            
    $ascolname 'Product Small Image URL';
            } else if (
    $field_names[$ab] == 'prodPrice') {
            
    $ascolname 'Product Price';
            } else if (
    $field_names[$ab] == 'extraFieldA') {
            
    $ascolname 'Extra Field A';
            } else if (
    $field_names[$ab] == 'extraFieldB') {
            
    $ascolname 'Extra Field B';
            } else if (
    $field_names[$ab] == 'extraFieldC') {
            
    $ascolname 'Extra Field C';
            } else if (
    $field_names[$ab] == 'extraFieldD') {
            
    $ascolname 'Extra Field D';
            } else if (
    $field_names[$ab] == 'extraFieldE') {
            
    $ascolname 'Extra Field E';
            }
            
            if (
    $ab == 0) {
            echo 
    '<tr><td align="left" style="border-bottom:1px solid #cccccc;">';
            echo 
    '<input type="text" value="eg. Amazon" id="'.$field_names[$ab].'" name="'.$field_names[$ab].'Data" onfocus="this.value=\'\'" />';    
            echo 
    '</td>';
            
            } else {

            echo 
    '<tr><td align="left" style="border-bottom:1px solid #cccccc;"><select id="'.$field_names[$ab].'" name="'.$field_names[$ab].'Data">
               <option selected="selected" value="999999">Please Choose...</option>'
    ."\n";

               
            
    $totalFields count($data_names);
                 for (
    $ac=0$ac $totalFields$ac++) {
                
    // limit characters to 50
                
    $t substr($data_names[$ac], 050);
                    echo 
    '<option value="'.$ac.'">'.$t.'</option>'."\n";
                }
                
            echo 
    '</select></td>';
            }
            
        echo 
    '<td align="left" style="border-bottom:1px solid #cccccc;"><img src="images/arrow1.gif" width="23" height="23" alt="" /></td>
        <td align="left" style="border-bottom:1px solid #cccccc;"><label for="'
    .$field_names[$ab].'">'.$ascolname.'</label></td>'."\n";
        
            if (
    $ab == 0) {
            echo 
    '<td align="left" style="border-bottom:1px solid #cccccc;">';
            echo 
    'Logo: <input type="file" name="logoUpload" />';    
            echo 
    '</td>'."\n";
            } else if (
    $ab == || $ab == || $ab == 9) {
                echo 
    '<td align="left" style="border-bottom:1px solid #cccccc;">';
                echo 
    '&nbsp;';    
                echo 
    '</td>'."\n";
            } else {
                echo 
    '<td align="left" style="border-bottom:1px solid #cccccc;">';
                echo 
    '<input type="text" value="" name="'.$field_names[$ab].'Title" />';    
                echo 
    '</td>'."\n";
            }

           } 
    Last edited by zulua; 04-14-2012 at 08:14 AM.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •