Text File DB -> PHP
Alright, question.
I'm writing a web log program in PHP; it writes data to a .txt file. I would like to be able to add editing capabilities; but i'm sort of unsure how to take the info from the .txt file and have it displayed in form boxes so it can be edited, then re-written. I went out and bought three books on PHP and none of them really cover the explode and implode functions in detail : which i understand it's essential to use the implode function to do what i want here. Any advice or better yet.. help ? -------------------------------------------- I'm still working on that same project - that was a post I made to another board, though i don't think it gets read much. Hopefully I can get a little more help here hehe. One answer I did get though sort of helped, but i'm still not clear on the subject: ---------------------- Code:
# you can read an entire file into an array using file |
What excactly is yout problem? How is your data stored and what should your view (in your textarea) look like? It would be helpful if you posted some example. Please let me know how your log file's content should look like and how the web-editable version should look like.
Thx so far, Gary |
Alright - i'm storing the posted data in lines of html. right now i've slimmed the project down quite a bit until I can figure out how to take the needed post and edit in another web form.
Here's whats being written to the text file Code:
$dbEntry = "<a href=\"mailto:$url\">$name</a>: $comment\n"; Anyway, the other board i'm doing the testing from is here http://www.deadlysin3.net/scriptTest and you can see the code i've written here http://www.deadlysin3.net/scriptTest/code/ The way the web-editable form looks really isn't a big deal. What i'd like though, is two text boxes: one for users name, one for url and one text area that the comments could be put into. If you need anymore information please let me know..I really appreciate the help, Thanks! |
OT: #3
Just out of curiosity:
Which one is #3? :) Or, where is the "official canon" of them to be found? Pride, Envy, Greed, Wrath, Gluttony, Sloth or Lust? :) Cheers, Tink P.S.: Mine would probably be Pride, but I'm working on it :) |
Well lol.. I don't think there is any given order for any of the deadly sins though I could be badly mistaken. I've always considered lust to be the third though ;)
|
So you want to parse a HTML-file. Well, that's not really a big deal. What you need is searching for patterns. If your HTML-file consequently has this format, you can simply extract its data line by line into an linear array containing the three strings.
Well, here's a piece of Code:
$fd = file("blah.txt"); I suggest you know what to write into "update.php"... It's just opening the HTML-text-file for write-access, a loop (like "for($i=0;$i<count($eMail);$i++){/*...*/}) and in that loop just the printing of the concated HTML-link. Remember: $i then is the index of all entrys in the arrays. That means you can keep you loop being as simply as follows: Code:
// $fd is the opened file Tip: instead of any output of "update.php" just insert the PHP-code Code:
header("Location: index.php"); // or whatever So far, Gary |
Oups - there should be a colon followed by an opening bracket instead of that smiley up there in the ereg()-funtion :)
|
hehe
Yeah I figured that ;) using your code Code:
<?php i've no idea what the problem is ;( me and regular expressions just don't get along |
Well I just tried it out myself and found the bug. It's not the reular expression (uff - I used regex a long time ago and still got it :)). It's been in the line before. The string did not end. Change it to
Code:
print "<form action=\"update.php\">\n"; PHP Code:
PHP Code:
So far, Gary |
Sorry about that smiley-link up there, I bet you know why it's there :)
|
ahhhh!
I think i've got the general idea now - I usually need to see a working example before I see what needs to be done. I really appreciate your help!! This smiley suits me so well : :newbie: heh |
That's why you came here: to learn things :)
I think you need the possibilities to be shown so you know them. To select the needed method comes after. We're not the kind of coders saying "we always have a solution, but it never matches the problem :) So have fun! Ehm: tell us when you've finished your stuff and I'm sure, we're gonna post some crap ;) So far, Gary |
All times are GMT -5. The time now is 05:46 AM. |