Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP Forms and creating a table

Options
  • 25-04-2007 1:28pm
    #1
    Registered Users Posts: 1,643 ✭✭✭


    Hello,

    Asking this query on behalf of a colleague - just to check whether something is possible - if not I guess we will get the site revised.

    Anyhow we have an admin section for a website where there are a series of PHP forms to update individual documents to be accessed via the internet. The document webpages are displayed as php pages.

    In one of the form fields we often require to create a table - which we hoped would be displayed as a regular table in the webpage when viewing the document. We used to do this by simply entering the html code (before we moved over to php).

    The query is whether there is a code/method of entering data in a php form so that the returned webpage will display a table instead of just the code

    e.g.

    <TABLE BORDER=5 CELLPADDING=5 CELLSPACING=5> <TR><TH>Year</TH><TH>Bugs</TH><TH>Sales</TH></TR> <TR><TD>1995</TD><TD>2.3</TD><TD>500,000</TD></TR> <TR><TD>1996</TD><TD>3.2</TD><TD>1,700,000</TD></TR> <TR><TD>1997</TD><TD>5.6</TD><TD>8,200,000</TD></TR> <TR><TD>1998</TD><TD>12.3</TD><TD>33,000,000</TD></TR> </TABLE>

    Thanks for any advice,

    JAK


Comments

  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    Definitely.

    Without fully understanding it, it should definitely be possible to create a form that basically asks you how big you want the table, then presents you with another form that's Y columns wide and X + headers rows high.

    Then you input the data and submit.

    Without actually seeing what it does, I can't really give more than this. Is this a CMS or a wiki you're using by any chance?


  • Registered Users Posts: 1,643 ✭✭✭Jak


    Well at the moment what we have is a series of forms on the admin backend where you can enter information under various headings. Now at the moment if we put text into these boxes it comes up just fine on the webpage as text.

    However, if we wanted to include bullets or italics or a table (much like one could do via these boards.ie post forms), it will just come up as the text of whatever code we put in. I presume this is because we have moved from html to php. But what we need is to get back the ability to edit and enter data in a format other than just plain text via our admin backend.

    I'm guessing with PHP we may need some recoding of the actual backend admin.

    I'm not sure what you mean by CMS or wiki unfortunately! Basically this is an open web resource for looking at various policies implemented. Just information.

    Thanks,

    JAK


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    To me, it sounds like you need a wiki. Basically, it allows you create whatever page you want, with any name you want.

    Text goes in, in a plain-text format, but you add certain punctutation to format it.

    For example, in dokuwiki, if enter the text

    ===== This is My Page =====

    Then the text "This is my Page" will appear as a Header 1, indicated by the marks around it.

    Anyway, I think I see what you're talking about now.

    What the problem at the backend is, is that PHP is parsing and transforming the text before it displays it on the browser. As you may know, when you use the open bracket symbol (<), an browser interprest this as your intention to open a tag, e.g. <table>.

    If you want to display an actual opening tag, you need to use a type of HTML control character, specifically "<". What the PHP script is doing, is going through all of your text, and changing every open bracket character, into this "<" character - so the browser doesn't see an open bracket, it's being told to literally display an opening bracket.

    Is this a custom-coded thing or something that was downloaded. If it was a custom thing, then I suspect that he didn't realise you would use HTML code, and so coded it to parse the text in case you unwittingly inserted some HTML code. :)


  • Registered Users Posts: 1,643 ✭✭✭Jak


    Aye was a custom job - so I guess there are no tags we are just forgetting to use which would allow us to submit a table through the current php form backend?

    If not I guess we will pull out the backend code and see what can be modified.

    Thanks for the advice.

    JAK


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    No matter how you write this as <table> or %lt;table> it should still display the table in your browser, but there is a posibility the code is striped off before goes in the database.
    If you have a textarea field in the back-end that is control by some text editor like FKeditor (which can be easily adapted into your end) then try to view the source.

    Have you got any live example we can look at?


  • Advertisement
  • Moderators, Politics Moderators Posts: 38,972 Mod ✭✭✭✭Seth Brundle


    louie wrote:
    No matter how you write this as <table> or %lt;table> it should still display the table in your browser,
    If you have > or < stored in a DB table it will not be used to help create HTML tags in the browser but to display the angle brackets instead.


  • Registered Users Posts: 1,643 ✭✭✭Jak


    So I view the source of the edit page on the backend system or simply look for the appropriate php file in the web folder?

    Basically the backend layout just has forms like this...

    forms.JPG

    At present the resulting pages are then shown on the web like this

    test.JPG

    We want to be able to format the text in the boxes (much like on boards) or to copy in tables and so forth. I think from what you folks are suggesting we may need to get a plugin loaded in for this functionality on the backend.

    Thanks for your time again,

    JAK


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    look into http://www.fckeditor.net/ very good.
    If you need help with it pm me


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    Jak wrote:
    So I view the source of the edit page on the backend system or simply look for the appropriate php file in the web folder?
    Pretty much.
    It's possible that the text is being altered before it's displayed, or more likely that it's altered just after you input it. So from this point of view, there are two possible files that may contain the code you're looking for.
    We want to be able to format the text in the boxes (much like on boards) or to copy in tables and so forth. I think from what you folks are suggesting we may need to get a plugin loaded in for this functionality on the backend.
    That would be the handiest option for your situation. There are plenty of free javascript plugins that allow you to turn a standard input textbox into a wordpad-style editor. Unfortunately, this would still require you to alter the php code to prevent it from altering your input. Indeed, fckeditor looks like an great version of that.

    Tables may still be a little outside what most of these can do.

    I still think for your purposes, a wiki may be very useful. They can be tough to get your head around when you've never used one before, but they're super useful for collaborative documentation.
    A brief overview is here:
    http://en.wikipedia.org/wiki/Wiki
    I know the very first line specifies "without the need for registration", but most wiki softwares allow you to restrict access so that guests may only read content.

    Let us know if you have more questions.


  • Registered Users Posts: 1,643 ✭✭✭Jak


    That's a great help thanks folks.

    The wiki is indeed a great approach, but at this stage of the game it would involve a lot of overhaul - there are already a few years worth of data in the database from the old system. I take your point though Seamus and I think for any similar work in the future that would be the route to follow alright.

    For the moment and our current needs, Fckeditor looks like it would be perfect - with even more functionality than we had hoped. However, the next question is what level of expertise is required to add this plugin - how long could it take and so forth? Also as a non-commercial are we ok to use the open license?

    Cheers for all the advice folks - am well out of my expertise area with this and it's great to get the options clear.

    JAK


  • Advertisement
  • Closed Accounts Posts: 1,200 ✭✭✭louie


    there is license link: http://www.fckeditor.net/license

    I think you should be OK there.

    Integration is easy enough. Download, unzip in a folder called (let's say FCKeditor), upload into the root of your website, then include it into the page:
    [php]
    <?php
    include("FCKeditor/fckeditor.php");

    ?>
    [/php]

    to make use of the file for a textarea field do as below:
    <!-- lets say your textarea name and id is details-->
    <?php
    $oFCKeditor = new FCKeditor('details');
    $oFCKeditor->BasePath = '/details/';
    $oFCKeditor->Value = 'Default text in editor';
    $oFCKeditor->Create();
    ?>
    <textarea name='details' id='details'></textarea>
    
    

    A lot of help can be found on the wiki page: http://wiki.fckeditor.net/Developer%27s_Guide/Integration/PHP


  • Registered Users Posts: 1,643 ✭✭✭Jak


    Thanks very much - we shall have a go! In so far as one ever has 'a go' at programming/coding.


Advertisement