The online racing simulator
help a php n00b <-_->
(4 posts, started )
#1 - CSU1
help a php n00b <-_->
...anyone here have a moment to spare with a complete n00b?

I has a problem. I need to write a script that:
  • Gets csv from http
  • extracts a number of fields and inserts into MySQL tables (field structure of web CSV does not match that of the MySQL table)
...
I absolutely and ultimately suck at PHP, but as far as reading a CSV file goes, I made a little example which could hopefully help you a bit.


<?php 
php
$data
;                                                    //Data read from .csv divided to lines and fields
$row 0;                                                //Total rows read
if(($handle fopen("sample.csv""r"))) {              //Try to open a .csv for reading
    
while (($line fgetcsv($handle0","))) {        //File opened successfully, read the file line by line
        
$data[$row] = $line;
        
$row++;   
    }
    echo 
"File read, total rows read: " . ($row) . "\n";
    
fclose($handle);                                     //Close the .csv file

    //Iterate through read data and print them on screen
    
for($i 0$i $row$i++) {
      
$num count($data[$i]);
      for(
$j 0$j $num$j++) {
       echo 
$data[$i][$j] . " ";
      }
      echo 
"\n";
    }
}


...
?>

If you replace the "sample.csv" with an actual http link, it should read the csv file from a remote resource just as easily.
#3 - CSU1


meh - I thought it was a good idea to purchase these womans clothing domains as the contained very popular search terms - turns out eCommerce website are a bit more tricky than im used too.

Fumbling through different parsing components for Joomla is just cack.

I guess I'll have to manually populate my store manufactures, vendors and products (almost one hundred thousand products) and I might be able to get the stock and pricing info auto update myself, I just don't see how on earth it's possible to auto grab products from any CSV that has such poor product category structure, for example, virtuemart uses an integer to identify categories and is auto incremented as they are added, I needed to change it to VARCHAR as any attempt to import the CSV into the correct category would first need an interpreter to cross reference the old INT category ID with the content of the category field in the CSV - it's all like this and very messy.

The single most annoying thing about all of this is the fact that suppliers wont use or agree on standard category names & structure...it gets confusing - was three in the morn and I was like :insane:

If it works out I guess I'll pay someone to come in and rebuild/sort out some things...
#4 - CSU1
Double Posts FTW !

Soo, I've spent the last X number of hours filling my store and making it beautiful only to realize that I'm running into a deal breaker.

I'm having trouble with this code:


<?php 
// Original Virtuemart Code:
// $Itemid = "&Itemid=".$this->getShopItemid();
// VM-Expert Hack – Start

// Strip the parameters from the $text variable and parse to a temporary array
$tmp_text=str_replace('amp;','',substr($text,strpos($text,'?')));
if(
substr($tmp_text,0,1)=='?'$tmp_text=substr($tmp_text,1);
parse_str($tmp_text,$ii_arr);

// Init the temp. Itemid
$tmp_Itemid='';

$db = new ps_DB;

// Check if there is a menuitem for a product_id (highest priority)
if ($ii_product_id=intval($ii_arr['product_id'])) {
$db->query"SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%product_id=$ii_product_id%' AND published=1");
if( 
$db->next_record() ) $tmp_Itemid $db->f("id");
}
// Check if there is a menuitem for a category_id
$ii_cat_id=intval($ii_arr['category_id']);
if ( 
$ii_cat_id && $tmp_Itemid=='') {
$db->query"SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%category_id=$ii_cat_id%' AND published=1");
if( 
$db->next_record() ) $tmp_Itemid $db->f("id");
}
// Check if there is a menuitem for a flypage
$ii_flypage=$ii_arr['flypage'];
if (
$ii_flypage && $tmp_Itemid=='') {
$db->query"SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%flypage=$ii_flypage%' AND published=1");
if( 
$db->next_record() ) $tmp_Itemid $db->f("id");
}
// Check if there is a menuitem for a page
$ii_page=$ii_arr['page'];
if (
$ii_page && $tmp_Itemid=='') {
$db->query"SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%page=$ii_page%' AND published=1");
if( 
$db->next_record() ) $tmp_Itemid $db->f("id");
}
// If we haven't found an Itemid, use the standard VM-Itemid
$Itemid "&Itemid=" . ($tmp_Itemid $tmp_Itemid $this->getShopItemid());

// VM-Expert Hack - End
?>

I've been told my problems will be solved if I replace a certain part of a php file to correct some crazy errors coded into VM (menu item ID's getting mixed up with Joomla ID's), this will heavily effect SEO if not corrected, and any SEO plugin components will not function because it just loops and 404's.

My problem is I don't code, I have tried to replace the code line-by-line but it gets medded up...am I right in assuming that where it sayes 'AND' that is not a new line???

EDIT: WTF the BB PHP tags answered my question LoLz

NM.....

help a php n00b <-_->
(4 posts, started )
FGED GREDG RDFGDR GSFDG