Reply to Re: reducing number...

Your name:

Reply:


Posted by peter on 10/21/06 09:38

> Not a php or sql wiz but working on a form that is linked to a sql
> database.
> I want to put a statement at the top of the form that says
> " there are currently '20' places remaining in this workshop".
> Each time a person submits a form I want the page to reduce the number by
> 1
> until when n=0 it displays in red 'there are no places available in this
> workshop'
>
> thanks
>
> plato
>
> I'm thinking it could work off the ID on the database.
>

You should not really use the ID for this type of thing. What you would be
best doing is is

$query = 'SELECT '.$places_available.'-COUNT(\'field_name\') FROM
table_name;';

if of course there are some places that should not be counted then use a
where clause on it. $places_available would be set in your php script to the
maximum amount of people that can be on the workshop. After the query before
displaying the form you should do a check to ensure the result is greater
than 0. You should also check if it is greater than 0 before submitting
their data to the database (in the event that someone has submitted at the
same time as someone else or has left the page open for some time before
submitting), this would of course stop over booking.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация