Jump to content

Is this possible with PHP somehow? If not, suggestions?


Jax2

Recommended Posts

I would like to figure out if something is even possible, and if so, how I might do it... if not, is there another way in which I could possibly do this? I'll explain:

 

I am creating a script (or trying to anyhow) that would allow people to create their own content, much like a story with multiple paths.

 

I have only figured out the first part, creating the first page and adding options and links to new pages.

 

User creates story title and brief description --> Story title saved to database, random link generator creates a random # from 1million to 9,999,999. Number is checked against another table that includes all links already generated, and creates a new temp random number if needed, until it finds a free number. That number becomes the first page of the story.

 

On the bottom of each page, the user can create up to 4 choices for the reader to choose from. Each choice is saved in the database along with the page number it came from. So now we're up to 5 possible pages. The user may also choose to make a page a "The End" page, meaning there will be no more links from that page, end of story.

 

HERE IS MY PROBLEM!

 

I do not know how I could easily allow the user to keep track of where they are in their stories.

 

What I mean is, if they start on page 1 and offer 4 choices, they will have to continue writing for each of the choices. As they continue adding pages, and more choices, it will become more and more difficult to remember which page has choices on it you haven't written content for yet.

 

What I would like to do somehow is create a map maybe, so for each page they do, it will add to the map, much like a family tree, branching out until each page is an end page and has no more choices. They would also have to be color coded, so, for example, if they offer 3 choices, and haven't written the content for each choice, the box on the map showing that page would be red. If they have completed the next page for each choice, the box would be green. This way, they can quickly glance at the "map" and see Oh, there is a page with 1 or more choices on it, but I haven't written a new segment for at least 1 of them, I need to go back to this page and continue it.

 

I really hope someone out there can make sense of what I am saying and tell me if there is any way to create a map, or a branch directory so to speak for their story. ANY suggestions would be helpful, as I'm at a complete loss now.

 

Thank you in advance, and if this interests you at all but I'm not clear on something, please let me know and I'll try to explain better!

Link to comment
Share on other sites

If I were trying to create something like this, I would create a database table that would contain all of the pages of every user. There would be a field for ID, user (who created the page), page title, page content, parent page, sibling pages, child pages, is_start and is_end (enums to represent if a start/end page). As you will have a maximum number of child and sibling pages, you could have 4 child page entries, and 3 sibling page entries. Or you could just have one field and them put the ID's of parents/siblings in as comma separated or pipe separated values (which you will process in PHP later).

So the rough mysql to create this table would look like this:

create table pages(
id,
user,
page_title,
page_content,
parent_page,
sibling_page_1,
sibling_page_2,
sibling_page_3,
child_page_1,
child_page_2,
child_page_3,
child_page_4,
is_start,
is_end
)

 

Obviously you'll need the data types etc, of which you'll be able to figure out.

 

Using a structure like that, you can query the database with the users name, and searching for is_start (which is the first page in the story). From there, you can grab the child pages of the start page, and then use arrays and loops to loop through the hierarchy of each story option until is_end is found..

 

I'm not sure if I've quite grasped your problem, nor whether my suggestions will actually help, but thought I would give you something so you can better explain the problem you are having :).

 

Denno

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.