pdf view

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
techker
Forum Commoner
Posts: 52
Joined: Fri Sep 02, 2005 9:53 pm

pdf view

Post 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?
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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.
techker
Forum Commoner
Posts: 52
Joined: Fri Sep 02, 2005 9:53 pm

Post by techker »

well its because in pdf i can merge files easy.there is lots of excell documents in one categorie.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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.
techker
Forum Commoner
Posts: 52
Joined: Fri Sep 02, 2005 9:53 pm

Post 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?
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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
techker
Forum Commoner
Posts: 52
Joined: Fri Sep 02, 2005 9:53 pm

Post 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]
techker
Forum Commoner
Posts: 52
Joined: Fri Sep 02, 2005 9:53 pm

Post by techker »

User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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.
techker
Forum Commoner
Posts: 52
Joined: Fri Sep 02, 2005 9:53 pm

Post by techker »

thx
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post 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.
Post Reply