Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Probably stupidly easy problem

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
andychannelle
LXF regular


Joined: Mon Apr 04, 2005 5:08 pm
Posts: 111

PostPosted: Sun Aug 13, 2006 12:54 pm    Post subject: Probably stupidly easy problem Reply with quote

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
View user's profile Send private message Visit poster's website
TheDoctor
LXF regular


Joined: Mon Jan 02, 2006 9:02 pm
Posts: 325

PostPosted: Sun Aug 13, 2006 8:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
nordle
LXF regular


Joined: Fri Apr 08, 2005 10:56 pm
Posts: 1500

PostPosted: Mon Aug 14, 2006 12:11 am    Post subject: Reply with quote

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
View user's profile Send private message
jjmac
LXF regular


Joined: Fri Apr 08, 2005 2:32 am
Posts: 1996
Location: Sydney, Australia

PostPosted: Mon Aug 14, 2006 3:20 am    Post subject: Reply with quote

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 Smile

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
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8453
Location: Warrington, UK

PostPosted: Mon Aug 14, 2006 8:47 am    Post subject: Reply with quote

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.
_________________
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
Back to top
View user's profile Send private message
andychannelle
LXF regular


Joined: Mon Apr 04, 2005 5:08 pm
Posts: 111

PostPosted: Mon Aug 14, 2006 10:05 am    Post subject: Reply with quote

My fears confirmed. Thanks for the advice. I'll get a book on MySQL/PHP...

Thanks
Back to top
View user's profile Send private message Visit poster's website
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8453
Location: Warrington, UK

PostPosted: Mon Aug 14, 2006 10:17 am    Post subject: Reply with quote

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.
_________________
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
Back to top
View user's profile Send private message
ollie
Moderator


Joined: Mon Jul 25, 2005 12:26 pm
Posts: 2749
Location: Bathurst NSW Australia

PostPosted: Mon Aug 14, 2006 10:39 am    Post subject: Reply with quote

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 Confused , 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 user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast