SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member
    Join Date
    Feb 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Php Code To Edit .html Page

    I am making a site(project). its an education portal, which consists of various pages like Notes(containing list of available notes), Papers etc..
    All these pages are simple html pages with table tag to display list of available contents. Now the problem is that
    I want to use PHP pages for admin login, where the admin enters the Name and description of the new notes and it is automatically added to the HTML table tags. ( this is because i dont want the tables content to be loaded from a database each time a user wants to see the available projects)


    Plzz help (No need to write and post code for this, just give me the basic idea how can it be done.. )

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    - Make a form in the admin page and have a text area.
    - Read the file (html or any files) with fread function and show the content in that text area.
    - Then admin will make changes and submit the page/form and write the changed contents to the same file with fwrite function.

    Hope you are well familiar with the basic PHP programming and you can do it yourself.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Addict Zarin Denatrose's Avatar
    Join Date
    Jan 2009
    Location
    Surrey BC, Canada
    Posts
    309
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I wouldn't have the PHP edit the HTML directly. You could use SQLite to store the data (to avoid using an extra server), then generate the HTML from that data and cache it so you don't need to regenerate the page every time.

  4. #4
    SitePoint Member
    Join Date
    Feb 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thnkx, but isnt there a way to edit the page directly. As i said before, what i had in mind was that in the admin page i would just add the name and short description of the project and the code would translate it into <td> code(this part i can do myself) and add it to the table tag in the html file automatically.

    Basically, isnt there a way to mark a specific location in a html file, which can be used to add any code via php

  5. #5
    SitePoint Member
    Join Date
    Feb 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @Zarin Denatrose
    The way i see it if i edit the html page directly it would save lots of access time. My priority is to keep the time as low as possible, thats why i want to use html pages and not connect with a DB. Why do u thinking editing html directly is not gud??

  6. #6
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Writing to a particular place in the file is bit of tricky work as far as i know. Since you cannot move the file pointer to the particular location. It will be at the end of the file if you are editing the file or it will empty the file. The technique will depend on how you open the file. As you said before i just gave a simple steps and functions that may work for you to read and write the contents to a file. I hope now you can do that reading whole html file and write it to the same file.

    But, i will still recommend you to go for database system for such things it will really make your life easier and safe too. It will not slow down your site.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  7. #7
    SitePoint Member
    Join Date
    Feb 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ohk.. so u mean i should make all pages as PHP and get the table data from the DB. Like a forum thread, Right??

  8. #8
    SitePoint Addict Zarin Denatrose's Avatar
    Join Date
    Jan 2009
    Location
    Surrey BC, Canada
    Posts
    309
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rajug has the right idea, though the reason I suggested SQLite is because you don't really have to connect to a database. It's stored as a local file, not a table on a server, but works like MySQL for reading and writing values.

    See http://php.net/manual/en/book.sqlite.php for more information.

  9. #9
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by yash1990singla View Post
    Ohk.. so u mean i should make all pages as PHP and get the table data from the DB. Like a forum thread, Right??
    Indeed, these forums also work in that way with database. PHP does saving the contents to the database and retrieving them to the user back in the browser from database. So create a database and have at least a table with couple of fields as per your requirement (id, name, description) and save the name and the description to those respective fields. Now when you retrieve them back to the browser then you must construct the table->tr->td or whatever you have in the design. This way you can manage the things easily. Hope you understand and can do the things yourself.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  10. #10
    SitePoint Member
    Join Date
    Feb 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ohk THANKX.. i will then make php pages and use db (will try to use sqllite)
    Thankx for such quick replies


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •