Jump to content

Selecting Specific Columns in SQL


asaad

Recommended Posts

HI all,

 

Am new here and kind of new to php too .. this is my first post :D

I have 2 questions:

This is a MySQL database named "items" 
items.jpg

1- Is there a way to show the sum of the blue cells using php, ie : 10 + 77 + 12 + 67

 

2- I will refer to Row as R and Column as C:
 

     how can I show the sum of everything ie:

      R1C1 + R2C1 + R3C1 + R4C1

      R1C1 + R2C1 + R3C1 + R4C2

      R1C1 + R2C1 + R3C1 + R4C3

      R1C1 + R2C1 + R3C2 + R4C1

      R1C1 + R2C1 + R3C2 + R4C

      R1C1 + R2C1 + R3C2 + R4C3

      R1C1 + R2C1 + R3C3 + R4C1

      R1C1 + R2C1 + R3C3 + R4C2

      R1C1 + R2C1 + R3C3 + R4C

      R1C1 + R2C2 + R3C1 + R4C1

      R1C1 + R2C2 + R3C1 + R4C2

      R1C1 + R2C2 + R3C1 + R4C

 

     and so on until showing all the 256 sums

 

 

Thank You Very Much in advanced 

Link to comment
https://forums.phpfreaks.com/topic/279763-selecting-specific-columns-in-sql/
Share on other sites

Thanks for your replys, here is an explanation that I believe will answer your questions :

the rows are Items for an online printing shop.. and the columns are the prices for different types. 

for example there is a type of pens for 10$,another type for  40$ ,and another for 80 and so on .. 

When a costumer wants to make an event he will need for example : 100 pens , 40 bags and 30 Shirts.

 

He will enter the amount of money he has in mind for the event : Ex: 3000$

The site will calculate what are the best types of pens, bags and shirt he can buy with his money ..

so the real equation is :

3000- ( pen type1 * 100 + bag type 1 * 40 + Shirt type 1 * 30 )= , if + or 0 then put to suggestions .
 

3000- ( pen type2 * 100 + bag type 1 * 40 + Shirt type 1 * 30 )= , if + or 0 then put to suggestions .

and so on ..
Thanks Again

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.