| View previous topic :: View next topic |
| Author |
Message |
andychannelle LXF regular
Joined: Mon Apr 04, 2005 5:08 pm Posts: 111
|
Posted: Sun Aug 13, 2006 12:54 pm Post subject: Probably stupidly easy problem |
|
|
Back in programming school, I never really got beyond HTML, and now I'm faced with a problem I just can't solve, so if any of you smart people can help me out that would be great!
I have a list on a website and I want to set it so that once an item is selected from the list, it becomes unavailable to other visitors. Does this sound easy with HTML/Javascript/PHP/Something else or - dan dan daaaaan - will it require the use of a database? |
|
| Back to top |
|
 |
TheDoctor LXF regular
Joined: Mon Jan 02, 2006 9:02 pm Posts: 325
|
Posted: Sun Aug 13, 2006 8:23 pm Post subject: |
|
|
A few basics to guide you to the right answer (in the spirit of teaching a man to fish):
- HTML is not a programming language but a markup language. That means you can't use it for processing. So it's no good for your purposes.
- Javascript is a programmig language, but it executes on the client side - ie it runs on the user's PC. This means it is useful if you had a list and wanted the user's browser to do something special if/when they picked an item. But it can't affect anything that happens on another user's PC. So that's a no-no for you.
- PHP is a server-side programming language, and therefore anything it does applies to all users. You could certainly use it for what you want to do, but you'd have some means of storing which items had already been chosen. Which means you're right: you're going to have to use a database as well.
Hope this makes things clear, even if it confirms that things may mean more work than you'd hoped. |
|
| Back to top |
|
 |
nordle LXF regular

Joined: Fri Apr 08, 2005 10:56 pm Posts: 1497
|
Posted: Mon Aug 14, 2006 12:11 am Post subject: |
|
|
Just to throw a couple of things, the database could be sqlite or java hsqldb so its really tiny.
But also, could you (if there are not too many) not store the values in a simple .txt file, then just do some text file manipulation via php? _________________ I think, therefore I compile |
|
| Back to top |
|
 |
jjmac LXF regular
Joined: Fri Apr 08, 2005 2:32 am Posts: 1996 Location: Sydney, Australia
|
Posted: Mon Aug 14, 2006 3:20 am Post subject: |
|
|
Something like a conditional expression using a flag to lock it. The flag gets set if it hasn't been selected before and allows the process into the conditional to return the value. It gets unset when unselected. If the flag is set on another attempt to retrieve it, it returns with a not available message ... something along those lines. I'm thinking in C though
jm _________________ http://counter.li.org
#313537
The FVWM wm -=- www.fvwm.org -=-
Somebody stole my air guitar, It happened just the other day,
But it's ok, 'cause i've got a spare ... |
|
| Back to top |
|
 |
nelz Moderator

Joined: Mon Apr 04, 2005 12:52 pm Posts: 7999 Location: Warrington, UK
|
Posted: Mon Aug 14, 2006 8:47 am Post subject: |
|
|
You'd need a way to store the flags, which could be a database but a simple file with one item per line would do just as well. Use PHP's ereg() function to check whether each item is in the list. _________________ Unix is user-friendly. It's just very selective about who it's friends are. |
|
| Back to top |
|
 |
andychannelle LXF regular
Joined: Mon Apr 04, 2005 5:08 pm Posts: 111
|
Posted: Mon Aug 14, 2006 10:05 am Post subject: |
|
|
My fears confirmed. Thanks for the advice. I'll get a book on MySQL/PHP...
Thanks |
|
| Back to top |
|
 |
nelz Moderator

Joined: Mon Apr 04, 2005 12:52 pm Posts: 7999 Location: Warrington, UK
|
Posted: Mon Aug 14, 2006 10:17 am Post subject: |
|
|
I use Professional PHP Programming from Wrox. I've had it several years, so it's a bit out of date now but I expect there's an updated version. I had all I needed on MySQL as well as PHP.
But I think an SQL database is overkill for a simple item list, a text file should do. _________________ Unix is user-friendly. It's just very selective about who it's friends are. |
|
| Back to top |
|
 |
ollie Moderator

Joined: Mon Jul 25, 2005 12:26 pm Posts: 2749 Location: Bathurst NSW Australia
|
Posted: Mon Aug 14, 2006 10:39 am Post subject: |
|
|
I have taught PHP - MySQL for a number of years and the best text book is PHP and MySQL Web Development by Laura Thomson & Luke Welling. It's now in third edition and you have to put up with US spelling, even though it is written by two Australians , and deals with creating and editing text files using PHP.
There would be nothing wrong with using PHP to edit the file containing the list to remove the radio button in the code. It might be a bit of work but careful planning and the use of variables would avoid having to setup a database to manage this. |
|
| Back to top |
|
 |
| View previous topic :: View next topic |
|