Jump to content

Simple: Write to middle of file in PHP!


Gtom

Recommended Posts

Hello, im pretty new to PHP and i am creating a system that allows the user to input information that is sent to a HTML file as a new line on a table, atm i am just making the php file add <tr><td>*info*</tr></td> and it works, but now i need the table to be complied the other way around with the newest information at the top so this basically needs me to have the header HTML with the table start, the newest entry then the older ones. I realize this means i will need to sepeare the file into 2 and put the new info in the middle somewhere so i was wondering the best method to do this?

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/48674-simple-write-to-middle-of-file-in-php/
Share on other sites

I am using a HTML file as my database and that cannot be sorted, i dont want to use a fancy MySQL database cause its more trouble than its worth and wouldnt offer any advantage.

I figured out the pointer thing so you can tell it what bit to write from but say if i tell it to write something after the 8th bit it overwrites anything after the 8th bit so is there a way i can make it not overwrite?

OK, i will reword this so its easier to help.

 

I need to input html into the middle of a html file using PHP, atm my system does the following:

 

User inputs data into HTML form > Clicks Submit > Info is sent to a HTML page and is added to the end of the file using append.

 

I need the system to be able to create a file that is like this

 

<Header HTML>

<Custom user info added via php>

<Footer HTML>

 

The Custom user info will be varying size because it gets bigger as people add more things.

 

Any help really appreciated!

Thanks again.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.