SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Hybrid View

  1. #1
    SitePoint Zealot zainabSULE's Avatar
    Join Date
    Apr 2009
    Location
    NG
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Drawing text from database...

    Hi

    So, here's the scenario. Am doing this page... this one's actually my personal page, and on it, there's a place to read dynamic poetry. I have close to 300 poems stored on my PC in word format. What I want to happen is that on the website, these poems change with every visit to the page.

    I understand this is PHP based, and I do quite a lot of stuff with php... but i've ne'er tried this one. Any help would be appreciated.

    Thanks
    Zainab

  2. #2
    SitePoint Addict
    Join Date
    Apr 2009
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are the poems in Word documents or stored in a database? Do you want them to appear sequentially, or at random?

    You'll have to give a bit more information if you want this to work.

  3. #3
    SitePoint Zealot zainabSULE's Avatar
    Join Date
    Apr 2009
    Location
    NG
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool

    hi

    i don't have a database yet on the site. All the poems are in word format on my PC alone. Its not yet online. What I wanna do is make this poetry available online, and also have a place where viewers can comment.

    So how do I even insert this poetry from MS Word to the database in the first place? I know a lot about dbases, but not when it comes to text...

    ThanKs...
    Z

  4. #4
    Non-Member
    Join Date
    Apr 2009
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could assign each poem to a variable (or store them in a database) and then create a random number say 1-10 via PHP. If $number = 1 echo $poem1. And so on and so forth.

  5. #5
    SitePoint Zealot zainabSULE's Avatar
    Join Date
    Apr 2009
    Location
    NG
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @ A2K. That's to advanced for me... I'm new to developing with php. I am primarily a person built born and bred at Design & Graphics.

    Besides, ALL the poems are in just 1 Word file. More than 200. So how do I now break them down??

    Thanks...
    zainab

  6. #6
    Non-Member
    Join Date
    Apr 2009
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know of any other way then to manually do it. My solution really isn't that advanced. Actually I tried the simplest way I could think of
    PHP Code:
    <?php
    srand
    (time());
    $random = (rand()&#37;9);
    echo("random number between 0 and 9 is: $random");
    if(
    $random==0){
    echo 
    $poem1;
    }
    else if (
    $random == 1){
    echo 
    $poem2;
    }
    //Keep doing that
    ?>
    Untested

  7. #7
    SitePoint Zealot zainabSULE's Avatar
    Join Date
    Apr 2009
    Location
    NG
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok... i'l try that.. but it kinda looks hard... but i use php my admin for my coding. so from d looks of it i have to seperate each poem and label it 0-1...

    seems....

    thanks.

    PS: is there any other option???

  8. #8
    Non-Member
    Join Date
    Apr 2009
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know of any other way. Maybe others could help, or simply put it all in a database, which from the sound of it is what you want, I just presented a simplified version.

    PS. If you put the poems in variables then dont put it in the file you output stuff. For readibility, put those poems in a seperate file then do include();

  9. #9
    SitePoint Zealot zainabSULE's Avatar
    Join Date
    Apr 2009
    Location
    NG
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi... thanks... ur reply was very helpful. i'm going to try it... its just that since am not a php guru i might have some difficulties.. but i knw u'll be there to help all the way...


    Z

  10. #10
    Non-Member
    Join Date
    Apr 2009
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you ever have any PHP problems just post back in this thread if it is relevant to this thread, or feel free to make another thread.

    ~


Bookmarks

Posting Permissions

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