Page 1 of 1

pdf view

Posted: Mon Feb 26, 2007 8:07 am
by techker
hey guys im making a web site for a distributor and he hase a big catalogue..

now it is all in excell so what i did is converted them to pdf and merged the categories.

now when you view a pdf it is not that nice on a web site.does anybody have any suggestion?or is there a script out there allready made for catalogues?

Posted: Mon Feb 26, 2007 9:14 am
by shiznatix
why are you using all PDF documents? Why not use HTML to make the pages? You would have much more control over the way that looks.

Posted: Mon Feb 26, 2007 9:27 am
by techker
well its because in pdf i can merge files easy.there is lots of excell documents in one categorie.

Posted: Mon Feb 26, 2007 9:29 am
by shiznatix
well what you SHOULD do is write a script that takes all the stuff from the excel file, puts it into a database, then you use php to dynamically build your pages.

If you are hell bent on PDF files, explain what "it is not that nice on a web site" means.

Posted: Mon Feb 26, 2007 9:37 am
by techker
for the pdf i like pdf but i was woundering if there is another way to display.and for the script.it wold be cool but no clue how.

you say it wold take the info from excell?

Posted: Mon Feb 26, 2007 9:45 am
by shiznatix
the best way is to first save the excel files as CSV format. this is the easiest to deal with in PHP. After you do that search google for parseing a CSV file in PHP and you will get many results. As you are parsing it you will just insert the data into a database. After that you will use PHP again to output everything dynamically.

Lets start with the getting everything into a database. Steps: make all excel files CSV files. open and parse the csv files with PHP and save all information to a database.

If you need help just ask

Posted: Mon Feb 26, 2007 9:51 am
by techker
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


i think it shold look like this?

Code: Select all

<?PHP

    //CONFIG VALUES TO SHOW WHICH COMPANY AND EMAIL LIST DATA IS ENTERED FOR
    $list_id = "85";
    $company_id = "40";
    
    //CONNECTS TO THE MYSQL DATABASE WHERE DATA WILL BE STORED
    $link = mysql_connect("localhost", "user","password") or die("Could not connect: ".mysql_error());
    $db = mysql_select_db("email_newsletter") or die(mysql_error());
    
    //SETS ROW VALUE OF 1
    $row = 1;
    
    //OPENS CSV FILE
    $handle = fopen ("good_csv.csv","r");
    
    //PARSES INFORMATION
    while ($data = fgetcsv ($handle, 1000, ",")) {
        
        //ONLY SELECTS RECORDS WITH A FIRST NAME, LAST NAME, AND EMAIL
        if($data[0] != "" && $data[1] != "" && $data[2] != "") {
        
            $data[0] = addslashes($data[0]);
            $data[1] = addslashes($data[1]);
            $data[2] = addslashes($data[2]);

            //FIRST QUERY INSERTS EMAIL AND LIST INTO SUBSCRIBERS TABLE
            $query = "INSERT INTO subscribers(`list_id`,`email`) VALUES('".$list_id."', '".$data[2]."')";
            $result = mysql_query($query) or die("Invalid query: " . mysql_error().__LINE__.__FILE__);
    
            //GRABS ID FROM QUERY FOR LOYALTYMAX CUSTOMER TABLE
            $subscriber_id = mysql_insert_id();

            //SECOND QUERY BUILDS CUSTOMER PROFILE IN LOYALTY CUSTOMER DATABASE
            $query2 = "INSERT INTO loyaltymax_customer(`first_name`,`email`,`company_id`,`last_name`,`list_id`,`subscriber_id`) VALUES('".$data[0]."','".$data[2]."','".$company_id."','".$data[1]."','".$list_id."','".$subscriber_id."')";
            $result2 = mysql_query($query2) or die("Invalid query: " . mysql_error().__LINE__.__FILE__);
            
            //PRINTS EACH RECORD
            echo("{$row}. {$data[0]}, {$data[1]}, {$data[2]} ");
            
                //IF MYSQL RESULT 1 & 2 ARE TRUE THEN PRINTS RECORD INSERTED, ELSE PRINTS ERROR    
                if($result = "1" && $result2 = "1") {
                    echo(" => RECORD INSERTED <br>");
                } else {
                    echo(" => ERROR <br>");
                }
        }
    //NEXT ROW
    $row++;
    }
    
    //CLOSES CSV FILE WHEN COMPLETE
    fclose ($handle);
    

?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Feb 26, 2007 9:52 am
by techker

Posted: Mon Feb 26, 2007 10:34 am
by shiznatix
techker wrote:found this to
http://www.csvreader.com/csv_samples.php
that is only for ASP it seams. The first example you posted there looks good except for a few things such as this line:

Code: Select all

if($result = "1" && $result2 = "1") {
it should be:

Code: Select all

if($result && $result2) {
and instead of the addslashes() command you should use mysql_real_escape_string()

try that one out and see if you can get it to work properly.

Posted: Mon Feb 26, 2007 10:37 am
by techker
thx

Posted: Mon Feb 26, 2007 6:51 pm
by mikeq
and watch out when doing comparisons in if statements

you had

Code: Select all

if ($result = "1" && $result2 = "1"){
this should have been

Code: Select all

if ($result == "1" && $result2 == "1"){
spot the double == signs, your if statement would never have worked.