Dear frends..
i have a problem..
there are four tables as below...
table vehicle_Mileage ( vehicle1, vehicle2......,vehicle36);
table vehicle_full_tank_capacity(vehicle1,vehicle2,...,vehicle36);
table vehicle_kilometer_covered_per_day(vehicle1,vehicle2....,vehicle36);
table Number_of_vehicle_Held_by_different_departments(department, vehicle1, vehicle2..... ,vehicle36);
(vehicle1, vehicle2.. vehicle36 are type of vehicles)
I need to find out the daily requirement of fuel by each vehicle if they cover $km per day.. that is..
vehicle1_fuel_requirement per day can be calculated(and should be calculated for each departement vehicles) -:
( (kilomere covered per day/mileage)+Full tank capacity)* no. of vehicle type 1
Now i want to save the result in table say :
table fuel_required_per_day_by_each_department(department, vehicle1, vehicle2,.. vehicle36)
...
i m new to php and mysql.. I need help.. iits a immediate rrequirement for me.. Its a SOS call... pls help
advance thanks..
with regards..
Monindradra masia
How to copy query to an array and then traverse through it.
Moderator: General Moderators
-
monindra1984
- Forum Newbie
- Posts: 14
- Joined: Wed Mar 18, 2009 10:35 am
-
monindra1984
- Forum Newbie
- Posts: 14
- Joined: Wed Mar 18, 2009 10:35 am
Re: How to copy query to an array and then traverse through it.
Anyone and great ones.. Pls give me a reply as soon as possible.. if you are not able to understand it.. I will explain in more clearly.. pls help me.. may god bless you all.. thank you..
Re: How to copy query to an array and then traverse through it.
It would be easier if you had one table with your fields
vehicle,milage,capacity,daily_km_range,department,fuel_needed
Otherwise you'll need to create unions of your tables to get all the bits and peices you need. Where with one table you can calculate fuel_needed and store it back in the same table. Your final result would then just be a sum(fuel_needed) order by department.
If you stick with your table structure here's how to use unions
http://www.mysqltutorial.org/sql-union-mysql.asp
Here's a little explanation and example of mysql_fetch_array in a loop.
http://www.tizag.com/mysqlTutorial/mysqlfetcharray.php
vehicle,milage,capacity,daily_km_range,department,fuel_needed
Otherwise you'll need to create unions of your tables to get all the bits and peices you need. Where with one table you can calculate fuel_needed and store it back in the same table. Your final result would then just be a sum(fuel_needed) order by department.
If you stick with your table structure here's how to use unions
http://www.mysqltutorial.org/sql-union-mysql.asp
Here's a little explanation and example of mysql_fetch_array in a loop.
http://www.tizag.com/mysqlTutorial/mysqlfetcharray.php
-
monindra1984
- Forum Newbie
- Posts: 14
- Joined: Wed Mar 18, 2009 10:35 am
Re: How to copy query to an array and then traverse through it.
Dear frends..
i have a problem..
I want to find the daily requirement of Fuel by different type of vehicles. Every vehicle has different mileage, average distance covered by different type of vehicles and The full tank capacity. Now each department has many different type of vehicles and department has different vehicles in different quantities. Dynmically i want to calculate the requirement of fuel by each diffferent department for different vehicles per day.
For that purpose i want to use arrays. I want to copy the tables to an array and do the calculations in php. Is this possiable. I was trying to copy array. I was not able to. Is ther anyway to do it.. I couldn't find any answers in the net. I need the solution very urgently.
there are four tables as below...
TABLE 1: Its stores the mileage of each vehicle type say vehicel1, vehicle2.. vehcile36
TABLE vehicle_Mileage ( vehicle1, vehicle2......,vehicle36);
TABLE 2: stores full tank capacity of each type of vehicle.
TABLE vehicle_full_tank_capacity(vehicle1,vehicle2,...,vehicle36);
TABLE 3: stores the average kilometer covered per day.
table vehicle_kilometer_covered_per_day(vehicle1,vehicle2....,vehicle36);
TABLE 4: Stores the number vehicles by each department of different type.
table Number_of_vehicle_Held_by_different_departments (department, vehicle1, vehicle2..... ,vehicle36);
(vehicle1, vehicle2.. vehicle36 are type of vehicles)
I need to find out the daily requirement of fuel by each vehicle if they cover $km per day.. that is..
vehicle1_fuel_requirement per day can be calculated for each type of vehicle for different departments.-:
( (kilomere covered per day/mileage)+Full tank capacity)* no. of vehicle
the result array should be stores the fuel required per day by x or y number vehicles of differnt types.The result should somehow as follows..
department | vehicle1 |vehicle 2 |........|vehicle36
-------------------------------------------------
A | x Litres| z litres |.........|N litres
-------------------------------------------------
B | y Litres| w litres |.........|K litres
.
.
.
.
.
.
.
.
.
i hope now.. its little more clearer...
advance thanks..
with regards..
Monindradra masia
i have a problem..
I want to find the daily requirement of Fuel by different type of vehicles. Every vehicle has different mileage, average distance covered by different type of vehicles and The full tank capacity. Now each department has many different type of vehicles and department has different vehicles in different quantities. Dynmically i want to calculate the requirement of fuel by each diffferent department for different vehicles per day.
For that purpose i want to use arrays. I want to copy the tables to an array and do the calculations in php. Is this possiable. I was trying to copy array. I was not able to. Is ther anyway to do it.. I couldn't find any answers in the net. I need the solution very urgently.
there are four tables as below...
TABLE 1: Its stores the mileage of each vehicle type say vehicel1, vehicle2.. vehcile36
TABLE vehicle_Mileage ( vehicle1, vehicle2......,vehicle36);
TABLE 2: stores full tank capacity of each type of vehicle.
TABLE vehicle_full_tank_capacity(vehicle1,vehicle2,...,vehicle36);
TABLE 3: stores the average kilometer covered per day.
table vehicle_kilometer_covered_per_day(vehicle1,vehicle2....,vehicle36);
TABLE 4: Stores the number vehicles by each department of different type.
table Number_of_vehicle_Held_by_different_departments (department, vehicle1, vehicle2..... ,vehicle36);
(vehicle1, vehicle2.. vehicle36 are type of vehicles)
I need to find out the daily requirement of fuel by each vehicle if they cover $km per day.. that is..
vehicle1_fuel_requirement per day can be calculated for each type of vehicle for different departments.-:
( (kilomere covered per day/mileage)+Full tank capacity)* no. of vehicle
the result array should be stores the fuel required per day by x or y number vehicles of differnt types.The result should somehow as follows..
department | vehicle1 |vehicle 2 |........|vehicle36
-------------------------------------------------
A | x Litres| z litres |.........|N litres
-------------------------------------------------
B | y Litres| w litres |.........|K litres
.
.
.
.
.
.
.
.
.
i hope now.. its little more clearer...
advance thanks..
with regards..
Monindradra masia
Re: How to copy query to an array and then traverse through it.
Your life would be a lot easier with all this data in one table because all the fields are interdependant.
If you insist on using 4 tables you can use union or join statements to retrieve your data.
http://www.tizag.com/mysqlTutorial/mysqljoins.php
Or just build one big temporary table from your multiple tables with unions.
http://www.tizag.com/sqlTutorial/sqlunion.php
However I recommend you put all your data into one table. Especially since you appear to be learning as you go, your multiple table idea will just make your life more complicated.
Table 1: vehicle,mileage,capacity,average_range,department,fuel_consumption
Just populate table 1 with all your data based on each physical vehicle. Yes you'll have extra entries for duplicate vehicle types, but if you want to get your project going without making the job more complicated then just build one big dataset in one table.
If you're asking for people here to show you how to write your queries and loop through the arrays, I doubt you'll get any help. You'll have to make an attempt yourself and post some code first.
If you insist on using 4 tables you can use union or join statements to retrieve your data.
http://www.tizag.com/mysqlTutorial/mysqljoins.php
Or just build one big temporary table from your multiple tables with unions.
http://www.tizag.com/sqlTutorial/sqlunion.php
However I recommend you put all your data into one table. Especially since you appear to be learning as you go, your multiple table idea will just make your life more complicated.
Table 1: vehicle,mileage,capacity,average_range,department,fuel_consumption
Just populate table 1 with all your data based on each physical vehicle. Yes you'll have extra entries for duplicate vehicle types, but if you want to get your project going without making the job more complicated then just build one big dataset in one table.
If you're asking for people here to show you how to write your queries and loop through the arrays, I doubt you'll get any help. You'll have to make an attempt yourself and post some code first.
-
monindra1984
- Forum Newbie
- Posts: 14
- Joined: Wed Mar 18, 2009 10:35 am
Re: How to copy query to an array and then traverse through it.
well thanks for the adivce.. actually i m running short of time thats why i was asking for such kind of help.. I look into your advice...
But i have very less time to practise.. i m trying to find some otherway.. thanks
But i have very less time to practise.. i m trying to find some otherway.. thanks
-
monindra1984
- Forum Newbie
- Posts: 14
- Joined: Wed Mar 18, 2009 10:35 am
Re: How to copy query to an array and then traverse through it.
i m able to copy query into an array and then doing the manipulation with arrays.. i m able to do it.. i will put the solution once i m ready with that.. pls comment on that if you find it very cumbersome.
Thank you........ may good bless all.. cheese!!!!!!!!!!!
Thank you........ may good bless all.. cheese!!!!!!!!!!!