|
#1
|
|||
|
|||
|
Hey,
I'v been working with html and javascript for a while but when it comes to php i really suck,I was wondering if anyone had a script to display random text,description & link,I have a small movie review site and I wanted to have a table that displays a new movie everytime you reload the page,with a small ss of the the movies,small description and link to the big description. thank you for the supportkind regards Mav |
|
#2
|
||||
|
||||
|
The php for this is easy. the issue is getting the information.
Would you store it in a database (best idea)? text file? Directly within the php code (worst idea)?
__________________
Daniel - <?php?> | <html>| Ich lerne Deutsch. | Studio l'italiano. | Estudiaba español. | Estudo português. | 日本語の勉強。| मैं हिन्दी सीखो | درس العربية |
|
#3
|
|||
|
|||
|
since i'm planning on iframing that page i think directly on the script would be easier.
|
|
#4
|
||||
|
||||
|
It would create a really bulky page, and be limited later, especially for changing the values later on.
It is a bit easier to code... might work for your purposes. Integrating with a database or maybe text file could help you later on... something to think about later. Basically... you could do something like this: PHP Code:
The bottom part takes that $n value and chooses the corresponding part of the array. If you need more than just the quotes, you can use more than one array, assigning in the same exact way, just using something different than "array" in $array[0]. Like $quote[0], etc. Then, when displaying them, just display all the variables there. Note: Note: As of PHP 4.2.0, there is no need to seed the random number generator with srand() or mt_srand() as this is now done automatically. that is from php.net. If you happen to be using a php version earlier than 4.2, you WILL need to seed the random number generator.
__________________
Daniel - <?php?> | <html>| Ich lerne Deutsch. | Studio l'italiano. | Estudiaba español. | Estudo português. | 日本語の勉強。| मैं हिन्दी सीखो | درس العربية |
|
#5
|
||||
|
||||
|
Code:
<?php
$quote = array(
"Quote one",
"Quote two",
"Quote three"
);
$quote = $quote[rand(0, count($quote) - 1)];
?>
...
<?php echo($quote); ?>
__________________
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP! |
|
#6
|
||||
|
||||
|
Indeed. I was going for simple, but that's much easier to manage. Good call.
Additionally, I figured my way taught what going on a little better, in hopes that maverick would learn php ![]() But... now he's got two example, so that's better anyway, right?
__________________
Daniel - <?php?> | <html>| Ich lerne Deutsch. | Studio l'italiano. | Estudiaba español. | Estudo português. | 日本語の勉強。| मैं हिन्दी सीखो | درس العربية |
|
#7
|
||||
|
||||
|
Lol, you may be right with the latter
__________________
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP! |
|
#8
|
||||
|
||||
|
Sure, but either way.
![]() (And, your example teaches me, so it's win-win-win )
__________________
Daniel - <?php?> | <html>| Ich lerne Deutsch. | Studio l'italiano. | Estudiaba español. | Estudo português. | 日本語の勉強。| मैं हिन्दी सीखो | درس العربية |
|
#9
|
|||
|
|||
|
thats for the help
guys,so how would the text document script gets abouts?
|
|
#10
|
||||
|
||||
|
Text document script?
__________________
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
|
|