Styles2304 Posted July 3, 2007 Share Posted July 3, 2007 Ok, so with your guys help I've managed to make my form save the data to a text file in a format that flash approves of (I think lol). Can someone point me to some tutorials that would help me with displaying the data saved in the text file in the input fields? I've found some but they were far to complex . . . they involved determining whether or not you wanted to save over that particular field and what not. I figure if all the data is loaded every time (and there isn't much of it) then if you change one field and just re-save the entire thing, that will work just fine. To see an example of what I'm doing goto http://www.nestent.net/images/myspace/moviedata.php Once you fill out a few of the forms and hit save, goto http://www.nestent.net/images/myspace/moviedata.txt to see the text file that the data is saved too. I don't know (with the formatting) if it's possible to bring that data BACK into the form. I'm sorry if these questions are horribly newbish I just don't yet know enough to even know the right questions to ask. Quote Link to comment Share on other sites More sharing options...
DeathStar Posted July 3, 2007 Share Posted July 3, 2007 Well, It's called Flat File Databases. here is an simple example: $file = file('db.txt'); foreach ($file as $lines) { list($ident,$text) = explode('|',$lines); if ($ident == $search){ $var = $text; } } echo '<input type="text" value="'.$var.'">'; Quote Link to comment Share on other sites More sharing options...
Styles2304 Posted July 3, 2007 Author Share Posted July 3, 2007 How do I determine which bit of information from the text file is actually displayed though? I'm gonna do some research on flat file databases though. Thanks for the tip. Quote Link to comment Share on other sites More sharing options...
DeathStar Posted July 3, 2007 Share Posted July 3, 2007 How do you mean? it searches the file for an word that matches the search variable. then gets the text after the |. Quote Link to comment Share on other sites More sharing options...
Styles2304 Posted July 3, 2007 Author Share Posted July 3, 2007 lol sorry . . . so I need to have "|" between the variables in the text file? Sorry . . . I know it's probably annoying but could you explain that bit of code assuming I know nothing? Not that bad but I mean can you like walk through each line? If it's an annoyance, don't worry about it, at least I'm pointed in the right direction. Quote Link to comment Share on other sites More sharing options...
DeathStar Posted July 3, 2007 Share Posted July 3, 2007 $file = file('db.txt'); 1|Text One 2|text two foreach ($file as $lines) { //Basically $lines == $file; list($ident,$text) = explode('|',$lines); Takes the text file search for the |'s Make first string before the | a variable called $ident. Make string after the | a valiable called $text if ($ident == $search){ //if the $ident is $search.. $var = $text; }// Make a Variable called $var. } echo '<input type="text" value="'.$var.'">'; // Put the variable called $var in the textbox. Hope that helps. Quote Link to comment Share on other sites More sharing options...
Styles2304 Posted July 4, 2007 Author Share Posted July 4, 2007 Gosh, I feel retarded . . . but it doesn't. My text file is setup like this: &hosturl=http://www.nestent.net/images/myspace/ &mtitle1=James Bond: Casino Royale&mimgurl1=http://imagecache2.allposters.com/images/PYR/CON6519DM-CR.jpg&mrate1=5&mreview1=Excellent Movie! Plenty of action but still a good story. A little faster than older James Bond movies but I recommend it! There are more lines . . . each the same but each are numbered differently. So how do I make what you're telling me apply to what I have in that text file? Quote Link to comment Share on other sites More sharing options...
DeathStar Posted July 4, 2007 Share Posted July 4, 2007 Okay, well. &hosturl=http://www.nestent.net/images/myspace/ &mtitle1=James Bond: Casino Royale&mimgurl1=http://imagecache2.allposters.com/images/PYR/CON6519DM-CR.jpg&mrate1=5&mreview1=Excellent Movie! Plenty of action but still a good story. A little faster than older James Bond movies but I recommend it! Should look like: hosturl=http://www.nestent.net/images/myspace/ mtitle1=James Bond: Casino Royale mimgurl1=http://imagecache2.allposters.com/images/PYR/CON6519DM-CR.jpg mrate1=5 mreview1=Excellent Movie! Plenty of action but still a good story. A little faster than older James Bond movies but I recommend it! Then just change the identifier. $file = file('db.txt'); foreach ($file as $lines) { // this one '|' to '=' list($ident,$text) = explode('|',$lines); if ($ident == $search){ $var = $text; } } echo '<input type="text" value="'.$var.'">'; Quote Link to comment Share on other sites More sharing options...
Styles2304 Posted July 4, 2007 Author Share Posted July 4, 2007 Ok, I'll give it a try but I don't know that I can change the syntax since ultimately, this file needs to be ready flash over all else. Quote Link to comment Share on other sites More sharing options...
Styles2304 Posted July 4, 2007 Author Share Posted July 4, 2007 the line echo '<input type="text" value="'.$var.'">'; Where do I put that and what is the .$var.? Quote Link to comment Share on other sites More sharing options...
Styles2304 Posted July 4, 2007 Author Share Posted July 4, 2007 well . . . I did this: <?php $file = file('moviedata.txt'); for each ($file as $lines) { list($ident,$text) = explode('=',$lines); if ($ident == $search) { $var = $text;} } echo '<input type="text" value="'.$var.'">'; ?> But when I run the page I get this error: "Parse error: syntax error, unexpected T_STRING, expecting '(' in /home/le3bl/public_html/images/myspace/moviedata.php on line 23" Line 23 is "for each ($file as $lines)" Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 4, 2007 Share Posted July 4, 2007 <?php $file = file('moviedata.txt'); for ($i=0; $i < count($file); $i++) { list($ident,$text) = explode('=',$file[$i]); if ($ident == $search) { $var = $text;} } echo '<input type="text" value="'.$var.'">'; ?> [/code[ Quote Link to comment Share on other sites More sharing options...
Styles2304 Posted July 4, 2007 Author Share Posted July 4, 2007 Ok well thanks, that fixed the error message. However, it still doesn't do what it's supposed to (unless I have it setup wrong.) It just has a random input box at the top of the form that does nothing and none of the other box show the variables they're supposed to. http://www.nestent.net/images/myspace/moviedata.php Check it out. The data is stored ../myspace/moviedata.txt Anyone have any ideas? Quote Link to comment Share on other sites More sharing options...
Styles2304 Posted July 5, 2007 Author Share Posted July 5, 2007 Ok . . . the way you guys listed may have worked but I didn't understand it so I did it my own my. I ended up making an array from the save.php info, serializing, and saving it. Then, just calling it up, unserializing it and accessing the variables that way. So there you have it. Thanks for all the help though. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.