andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh? If you wish to use any of these in a commercial system, please refer to the payment plan.


Choose A Story Instead?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> MadLibs
View previous topic :: View next topic  
Author Message
tangeyj
Newbie


Joined: 05 Nov 2004
Posts: 2

PostPosted: Fri Nov 05, 2004 3:27 pm    Post subject: Choose A Story Instead? Reply with quote

Hi! Great script! Have a question though.... when testing out the script I started wondering if there was anyway to have an initial page which allowed for you to choose WHICH story to use, rather than have it randomly chosen. So for example there would be a page that asks (using the example stories) something to the effect of 'would you like a story about a beach? or a story about a trip to the mall'? and then you'd be able to click on either and then have the form for that story be the one to load.

Is this possible cause I haven't a clue how to do it!

Thanks so much,
T
Back to top
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Fri Nov 05, 2004 4:16 pm    Post subject: Reply with quote

Hi, and welcome to the board!

Haven't tried this out yet, but what you could try is this.

In the 'getStory' method, change these lines:

PHP:
<?php if ($_POST['id'])
{
    
$file $_POST['id'];
?>


to read:

PHP:
<?php if ($_REQUEST['id'])
{
    
$file $_REQUEST['id'];
?>


And that should really be it. You just need to pass the id of the story you want. to the script. If you're using a database as storage, it'd be the id numberof the row, else it'd be the file name.

So say you had your index file like this:

PHP:
<?php <html>
<
body>

<
p><a href="story.php?id=beach.txt">The Beach</a></p>
<
p><a href="story.php?id=car.txt">The Car</a></p>

</
body>
</
html?>


Then story.php would be something like:

PHP:
<?php <html>
<
body>
<?
php

    
require_once('class.madlibs.php');
    
$ml =& new madlibs();
    
$ml->useFS('./stories''.txt');
    
$ml->displayMadlib();

?>
</body>
</html> ?>


Give it a whirl and let us know how you get on.

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
tangeyj
Newbie


Joined: 05 Nov 2004
Posts: 2

PostPosted: Fri Nov 05, 2004 4:57 pm    Post subject: Reply with quote

Works beautifully! You rock!
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> MadLibs All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group