Technical Discussion
  >> Web Design / HTML / Web hosting Forum


Register (or login) on our website and you will not see this ad.


These posts have been archived and can no longer be replied to or modified.
  Print Thread
Standard User deleted
(deleted) Wed 25-Nov-09 21:12:56
Print Post

Amending tables


[link to this post]
 
Ok, it's about time I make it somewhat easier for my clients to update certain things on their websites without screwing it up.
Now I know how to create a secure login page that pulls info from a database, I know how to pass sessions around so a logged in user can see extra things that a non logged in user can't and I also know how to set user access rights, so someone set as say "administrator" can see more than "standard user".
I know how to pull information out of a table and display it on a webpage and finally I know how to add more data to a table.
What I don't know how to do is make it very simple for someone to delete information, or append extra data to a field (e.g. to correct a typo).

I hope you're all still following, this is the page I'm going to be working on. At the moment all data is hardcoded into the page (since it's live). What's the best way going about this? Do I create a table for each make, or could I have a field called make, that it can refer to when adding extra data (this sounds the most logical way). How can I get it to sort the data alphabetically and how can I allow someone to delete data no longer needed/append to an item already seen?

Cheers,

Dan
Standard User deleted
(deleted) Wed 25-Nov-09 21:34:31
Print Post

Re: Amending tables


[re: deleted] [link to this post]
 
Not quite sure if I'm with you, but I would create the page dynamically using a form to display data loaded from a database. How exactly you do that depends upon what server software is being used. For IIS you'd use ASP.NET, with the data being displayed by data grid components that would be editable by authorized users. For Apache you would do something similar using PHP or Perl.

Perhaps I've misunderstood your question?
Standard User deleted
(deleted) Wed 25-Nov-09 21:43:32
Print Post

Re: Amending tables


[re: deleted] [link to this post]
 
Slightly, I'm using PHP, I want to pull information out of a database and display it on a webpage as a table - that I can do. But what I need to be able to do (what I'm not sure about) is make a form up or something similar so that the logged in user can amend the table. I have an idea on how they can add new data to the table, but I'm not sure on how they can remove data from the table or amend data if a typo is made.
Adding to that I'm not quite sure how I can make the table sort the data alphabetically.

I hope that makes a bit more sense...

Cheers,

Dan


Register (or login) on our website and you will not see this ad.

Standard User Kenneth
(legend) Wed 25-Nov-09 21:50:18
Print Post

Re: Amending tables


[re: deleted] [link to this post]
 
First I suggest you read up on SQL injection attacks (which can be done via post as well as get) and ensure all php database scripts are not something the webserver can serve up

When I have allowed users to edit things like news Item entries - I used TinyMCE to give a HTML WYSIWYG editor for them to edit the data used to generate the page (I recall issues trying to get styles to work )

However for the page you are working on - I would have a set of edit pages (which would be unavailable to non-admins).
There would be a page where they can show a list of items (probably a group so not all items) - and next to each would be a delete button and an Edit Button - there would also be a new button

  • Delete Button - would delete the row on a post and redisplay updated list
  • Edit Button - would lead to another form (maybe popup) with all details on a form - the submit would update the entry and redisplay list (force update if popup)
  • Add Button - same/similar form as Edit - but create new entry instead of updating

always validate user is who you expect (session) before updating DB

To order the entries, you can make SQL return them in an order you desire - e.g.

select name, partno from spares.spareparts order by name;

Ken

When arguing with a fool, pause and ponder - are they also arguing with a fool

Edited by Kenneth (Wed 25-Nov-09 21:51:08)

Standard User deleted
(deleted) Wed 25-Nov-09 21:58:57
Print Post

Re: Amending tables


[re: deleted] [link to this post]
 
There are several different ways that you could approach this. With ASP.NET I'd use an editable data grid, which would take care of everything for you, but it's not quite so straightforward with PHP.

What about, in "edit" mode, having a couple of buttons beside each row, "modify" and "delete". "Delete" would do the obvious, "modify" would bring up a form with the details of the current row which could be edited and then written back to the database. To add new records you'd just have an "Add" button somewhere on the form that displayed a blank row to be filled in.

Sorting the data depends upon what form of database you are using. If it's an SQL database (mySQL - something like that), then it's just a matter of using an "ORDER BY" phrase in your "SELECT" statement. Or is the database just a text file?

Edit: Whilst I was composing that I see that Kenneth has posted a very similar suggestion (shows it must be a good one!).

Edited by deleted (Wed 25-Nov-09 22:00:35)

  Print Thread

Jump to