Quick PHP/MySQL data question...

Discussion in 'PHP' started by timothius, Jan 21, 2008.

  1. #1
    Hello Everyone! Quick question here...

    Alright, say I have a MySQL database setup that will store a whole pile of short stories or poems. What kind of data column do I use to store that data in the table that has information about the writing? Just a huge VARCHAR (?) I mean, I doubt there will be too many that will be over 25,000 characters... but is that the best way to do that?

    Also, what is the best way to INPUT this data? I tried LOAD DATA INFILE for a couple entries, but the problem with that is that you've got this HUGE long string, and it's virtually impossible to edit.

    Anyone know the proper way of doing any of this???

    I THANK-YOU in advance!!!! :)
     
    timothius, Jan 21, 2008 IP
  2. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #2
    Well for the column type, you would use "TEXT".

    Your second part I don't udnerstand, do you want to input data to the datbase or retrieve it from the db?
     
    blueparukia, Jan 21, 2008 IP
  3. timothius

    timothius Active Member

    Messages:
    136
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #3
    TEXT, eh? hmmm....

    Yes, I need to first input it into the db. I would like to also know how I control where paragraphs end and such. I assume with <br /> tags... and what is the best way to format it? Thanks.
     
    timothius, Jan 21, 2008 IP
  4. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #4
    Just leave it as a raw string, and use <p> tags around paragraphs, and in your css have something like:

    
    p
    {
    padding:15px;
    }
    
    Code (markup):
    Eliminates the need for br tags.

    Your PHP could go something like this:
    
    <?php
    
    $article = "Article content";
    
    $query = "INSERT INTO table_name (column_name)
    VALUES ('".mysql_real_escape_string($article)."')";
    
    ?>
    
    PHP:
    Something like that.
     
    blueparukia, Jan 21, 2008 IP
  5. timothius

    timothius Active Member

    Messages:
    136
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #5
    Er... well, then I would have to manually insert <p> </p> tags into the TEXT string right? But yes, that's a better idea than using 2 <br /> tags per paragraph.

    I didn't quite understand about what is the best way to insert 100s of these poems and stories, and to format them at the same time. Are you meaning creating a Content Managment System from scratch? I already have them in word (doc and txt) files, so I was hoping for an easy way to insert them into my database? Possibly with LOAD DATA INFILE??? Then I could also save those statements for easy re-build.
     
    timothius, Jan 21, 2008 IP
  6. HuggyStudios

    HuggyStudios Well-Known Member

    Messages:
    724
    Likes Received:
    20
    Best Answers:
    26
    Trophy Points:
    165
    #6
    Ues a wysiwyg editor and just insert all of the html and the contnet.

    Tinymce is a good one.
     
    HuggyStudios, Jan 21, 2008 IP
  7. timothius

    timothius Active Member

    Messages:
    136
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #7
    Thanks, but I want to set this site up as a dynamic database driven website...

    I already makes lots of HTML sites, but this isn't what I want in this instance.
     
    timothius, Jan 21, 2008 IP
  8. HuggyStudios

    HuggyStudios Well-Known Member

    Messages:
    724
    Likes Received:
    20
    Best Answers:
    26
    Trophy Points:
    165
    #8
    That's what I meant. Take the posted data from the qysiwyg editor add it into a database as a binary format.

    Then just print();

    Simple mate.
     
    HuggyStudios, Jan 21, 2008 IP