How to make this query?

Hello,

How to make this query?
include “./includes/config.php”;

SELECT * FROM multiswitch WHERE input=‘10’ AND output=‘20’ AND multiswitch_type=‘FINITE’ AND stock=‘1’
SELECT * FROM multiswitch WHERE input=‘10’ AND output=‘12’ AND multiswitch_type=‘CASKADE’ AND stock=‘1’

<=If do not have any one in stock,query this=>

SELECT * FROM multiswitch WHERE input=‘10’ AND output=‘20’ AND multiswitch_type=‘CASKADE’ AND stock=‘1’
SELECT * FROM multiswitch WHERE input=‘10’ AND output=‘12’ AND multiswitch_type=‘FINITE’ AND stock=‘1’

How to make this query?

Thanks

[php]include “./includes/config.php”;

$sql = mysql_query(“SELECT * FROM multiswitch WHERE input=‘10’ AND output=‘20’ AND multiswitch_type=‘FINITE’ AND stock=‘1’”);
$sql1 = mysql_query(“SELECT * FROM multiswitch WHERE input=‘10’ AND output=‘12’ AND multiswitch_type=‘CASKADE’ AND stock=‘1’”);

if(!$sql && !$sql1){
$sql = mysql_query(“SELECT * FROM multiswitch WHERE input=‘10’ AND output=‘20’ AND multiswitch_type=‘CASKADE’ AND stock=‘1’”)
$sql1 = mysql_query("SELECT * FROM multiswitch WHERE input=‘10’ AND output=‘12’ AND multiswitch_type=‘FINITE’ AND stock=‘1’ ")
}[/php]

you can try that…either way you need an if() statement

Also, if those columns are type defined as INT or any other number data type, you don’t need quotes around the number. and always add or die(mysql_error()) to the end of the query, otherwise you’ll never know if there’s an issue with it.

Hello,

@mdahlke, did not work
@richei, Thank you for Alert

This I want to do:
This is the rule:

Which one is the “Cascade” or “Finite” is not important.
It is important that any of them should be “Finite”. (by stock status)

$input=10;
$output=32;
NOTE: The numbers in bold represent the output

                                               [b]32[/b] output FINITE

<=If not in stock,query this=> 16+16=32 output. one of Multiswitches is CASCADE other one is FINITE
<=If not in stock,query this=> 24+8=32 output. one of Multiswitches is CASCADE other one is FINITE
<=If not in stock,query this=> 20+12=32 output. one of Multiswitches is CASCADE other one is FINITE
<=If not in stock,query this=> 12+12+8=32 output. two of Multiswitches are CASCADE other one is FINITE
<=If not in stock,query this=> 16+8+8=32 output. two of Multiswitches are CASCADE other one is FINITE
<=If not in stock,query this=> 8+8+8+8=32 output. three of Multiswitches are CASCADE other one is FINITE
<=If not in stock,query this=> 24+12=36 output. one of Multiswitches is CASCADE other one is FINITE
<=If not in stock,query this=> 20+16=36 output. one of Multiswitches is CASCADE other one is FINITE
<=If not in stock,query this=> 20+8+8=36 output. two of Multiswitches are CASCADE other one is FINITE
<=If not in stock,query this=> 16+12+8=36 output. two of Multiswitches are CASCADE other one is FINITE
<=If not in stock,query this=> 12+8+8+8=36 output. three of Multiswitches are CASCADE other one is FINITE
<=If not in stock, give this message=> “Product is not available”

Database: http://www.teklif.uzayforum.com/multiswitchler.rar

This print Sample:

How to make this query?
Regards
Adem GENÇ

This looks really familiar, didnt we do something like this already?

Yes, 8,12,16,20,24 output, for one item
Now, for system CASCADE
Sample 25…100 for output
Turkish “SONLU”, English “FINITE”
Turkish “KASKAD”, English “CASCADE”

I didn’t expect it to work, all i’m saying is you some kind of if-else statements. It was not meant to be a problem solver.

There’s a couple of things i don’t understand.

1 - where are you determining the input and output? where is the math being done? and
2 - is there a column that keeps track of how many switches are in stock?

Basically, i can’t really show you how to do the query because i don’t know where the information is coming from.

I’m thinking that the information might need to be re-organized like what was done in the other thread

Input and output are determined on previous pages. Here comes in a variable. Here is no problem.

No, there is not. Admin determines status of stock.
There are products in stock => “1”
There isn’t product in stock => “0”
There are two options.
Products in stock don’t decrease when they are sold.

Database: http://www.teklif.uzayforum.com/multiswitchler.rar

Input / Output. Here is no problem.
$input=10;
$output=32;
Every brand, which realized their condition, has a table.
Every brand has a radio button.
When I select the readio button, I want to take ID and amount of products in table.

Best Regards
Thanks
Adem GENÇ

Sponsor our Newsletter | Privacy Policy | Terms of Service