SitePoint Sponsor |
|
User Tag List
Results 1 to 10 of 10
Thread: Drawing text from database...
-
Apr 10, 2009, 10:19 #1
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
ZainabZainabSule
www.pishondesigns.com
-
Apr 10, 2009, 10:46 #2
- 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.
-
Apr 10, 2009, 10:56 #3
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...
ZZainabSule
www.pishondesigns.com
-
Apr 10, 2009, 11:01 #4
- 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.
-
Apr 10, 2009, 11:11 #5
@ 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...
zainabZainabSule
www.pishondesigns.com
-
Apr 10, 2009, 11:48 #6
- 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()%9);
echo("random number between 0 and 9 is: $random");
if($random==0){
echo $poem1;
}
else if ($random == 1){
echo $poem2;
}
//Keep doing that
?>
-
Apr 10, 2009, 11:59 #7
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???ZainabSule
www.pishondesigns.com
-
Apr 10, 2009, 12:02 #8
- 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();
-
Apr 10, 2009, 12:09 #9
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...
ZZainabSule
www.pishondesigns.com
-
Apr 10, 2009, 12:12 #10
- 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