PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old September 26th, 2002, 12:33 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 26
doin calculation..

hi pple,
i have a problem which need help frm u guys! just wondering how will i be able to update the database to check if i still have avaiable bike to rent? lets say i wanna rent 5 bikes but the database only left 3 bikes. how am i suppose to do such that it will inform the user that there is no enough bikes for rent? i also wanna do such that if someone returned a bike, i am able to update with 1 more bike for rental?

thx... i really need some guidance and help here.. thx thx..

Reply With Quote
  #2  
Old September 26th, 2002, 12:46 PM
Matt Matt is offline
Contributing User
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 12 m 16 sec
Reputation Power: 8
RE: doin calculation..

Well, you really need to do some database planning here. A very basic way to do this would be to have a table (called bikes) that has the following fields:

id - this will be a unique id for each bike
available - either 0 or 1. 0 being not available, 1 being available.

Then you can query the database like so:

SELECT count(*) AS available_bikes FROM bikes WHERE available = 1

the number that is returned is the number of bikes available for rent. When you get a bike back (let's assume bike 4) and you want to update its availability, you would run a query like so:

UPDATE bikes SET available = 1 WHERE id = 4

the same hold true when a bike is checked out and you want to update it:

UPDATE bikes SET available = 0 WHERE id = 4

Hope that helps...

Reply With Quote
  #3  
Old September 26th, 2002, 12:51 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 26
RE: doin calculation..

thxx.. but what i having now is huge database. i have 5 types of bikes, and for each type of bike, i have around 10 bikes. if given such case, how can i do it then? i cant possible give a id each for the ( 5 * 10 ) bikes?

is there any ways to do it?
thx..

Reply With Quote
  #4  
Old September 26th, 2002, 12:55 PM
D1NGO D1NGO is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Perth, Australia
Posts: 221 D1NGO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: doin calculation..

in that case you could create two tables. One being the one matt showed you, and another one which has the five types of bikes. ie. it would contain an id field - being unique id of bike type, then in the table matt showed you, create another column called parent_id, and have that being the same id as the id of its type in the other table...hope that made sense..

Reply With Quote
  #5  
Old September 26th, 2002, 01:09 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 26
RE: doin calculation..

err.. maybe the way i phrase my idea is a little messy.. let me rephrase again..

we are a bike storage company. so when user want to get their bikes back from us... they got to fill in a bike release order form.

QNS1: how would the user know that there is enough bike avaiable to taken out without them checking the database? Ex. let say if they wanna take out 5 bikes, but then we have only 3 bikes left in storage! so how to tell them there is no enough bikes to be taken out?

QN2: how do we delete a record from the database when the bike is taken out and also how to add when user store their bike with us?

hope you are clear with the picture.. thx ~


Reply With Quote
  #6  
Old September 26th, 2002, 01:36 PM
Matt Matt is offline
Contributing User
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 12 m 16 sec
Reputation Power: 8
RE: doin calculation..

I would really need to see your database structure...can you provide a dump of the structure?

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > doin calculation..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.


© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 7 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek