Results 1 to 14 of 14
  1. #1
    Join Date
    Jul 2007
    Posts
    6

    Is a "linking" table the answer...?

    I have this huge multi-page form that writes to a database. I then have a pdf generator that will grab data from only some of the questions of the form. Also some of the answers to those questions may be repeated on the pdf form (like name, phone).

    What would the best way be for my pdf-generator to get the data from the database?

    Thanks!

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    I vote for SQL.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Jul 2007
    Posts
    6
    Yes, I am using sql (mysql) and php. I'm just wondering what the best way to accomplish the task would be...

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    write php code to query the mysql database for the data desired, then use a pdf converter which you can invoke from php to produce the pdfs desired
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Jul 2007
    Posts
    6
    Quote Originally Posted by r937
    write php code to query the mysql database for the data desired, then use a pdf converter which you can invoke from php to produce the pdfs desired
    OK, thanks for the response! However, I only want some of the data. The problem is that the data I want is arbitrary. I can't really think of any 'where' or 'limit' clauses to add to the sql statement that would solve the issue.

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by z1freeride
    OK, thanks for the response! However, I only want some of the data. The problem is that the data I want is arbitrary. I can't really think of any 'where' or 'limit' clauses to add to the sql statement that would solve the issue.
    If it is arbitary then why do you need a where clause?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  7. #7
    Join Date
    Jul 2007
    Posts
    6
    I need to do something like this then:

    select value from table where some_id = 1,5,13,14,15,21,24,26,27. Is there anyway to do that without a bunch of or's (like some_id=1 or some_id=5 or some_id=13, etc)?

  8. #8
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    where some_id in ( 1,5,13,14,15,21,24,26,27 )
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  9. #9
    Join Date
    Jul 2007
    Posts
    6
    ok I think that's what I'll do! Thanks!

  10. #10
    Join Date
    Jul 2007
    Posts
    6
    Quote Originally Posted by r937
    where some_id in ( 1,5,13,14,15,21,24,26,27 )
    Can those list of numbers be a variable in php?


    $id_list = "1,5,13";

    select some_id from table where some_id in $id_list

    ??

  11. #11
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    yes they can but i don't know the exact syntax as i don't speak php
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  12. #12
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Quote Originally Posted by pootle flump
    I vote for SQL.
    Now that was a very MOwen-ish answer
    Inspiration Through Fermentation

  13. #13
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    If it helps ...
    Code:
    $id_list = "1,5,13";
    
    $sql = "select name, phone from MyTable where id in ( $is_list )";
    
    $result=mysql_query( $sql ) or die( "Issue with " . $sql );
    But remember that the $id_list variable must have one or more numbers in it separated by commas.

    Mike

  14. #14
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    if you are struggling with your PDF generator.. whatever that is, you could write your own PDF file based on your dataset.

    I've used PDFLib from http://www.ros.co.nz/pdf with success before.... it can be a bit of a pain at times
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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