How this query?

Hello,

I’m sorry, my English is bad

8x8 -> if this is not available -> 8x12
8x12 -> if this is not available -> 8x16
8x16 -> if this is not available -> 8x20
8x20 -> if this is not available -> 8x24
8x24 -> if this is not available -> 8x32

9x8 -> if this is not available -> 9x12
9x12 -> if this is not available -> 9x16
9x16 -> if this is not available -> 9x20
9x20 -> if this is not available -> 9x24
9x24 -> if this is not available -> 9x32

10x8 -> if this is not available -> 10x12
10x12 -> if this is not available -> 10x16
10x16 -> if this is not available -> 10x20
10x20 -> if this is not available -> 10x24
10x24 -> if this is not available -> 10x32

14x8 -> if this is not available -> 14x12
14x12 -> if this is not available -> 14x16
14x16 -> if this is not available -> 14x20
14x20 -> if this is not available -> 14x24
14x24 -> if this is not available -> 14x32

17x8 -> if this is not available -> 17x12
17x12 -> if this is not available -> 17x16
17x16 -> if this is not available -> 17x20
17x20 -> if this is not available -> 17x24
17x24 -> if this is not available -> 17x32

Sample Table

Sample
$source_input=10;
$source_outpu=12;

OR

Sample
$source_input=14;
$source_outpu=16;

include “./includes/config.php”;

$sql=mysql_query(“SELECT * FROM multiswitch WHERE input_x_output=’???’”);

How this query?

Best Regards

Really not understanding what the problem is.

Thank you for your reply

If the product does not exist, the next one find
produk stock: no/yes

Thanks

i think he wants to run a query then check the returned rows of the query if returned rows == 0 then print 'produk stock: n’o, if > 1 then print ‘produk stock: yes’

am i right?

I’m a beginner
Can you write a sample code?

Thanks

ima use the same quey you provided

[php]
$sql=mysql_query(“SELECT * FROM multiswitch WHERE input_x_output=’?’”) or die(mysql_error());

//fetch the result of query into an array called $rows
$rows = mysql_fetch_assoc($sql) or die(mysql_error());

//let says that in your database you have field named stocks, which holds the number of items left.

//check if stock is greater than one.
if ($rows[‘stocks’] > 1)
{
echo ‘produk stock: yes’; // we have stocks
}else
{
echo ‘produk stock: no’; //we don’t have stocks
}
[/php]

is that what you neeed?

Thank you for your help

Sample:
input_x_output=‘8X8
we don’t have stocks 8X8
(Next one/Latter 8X12) OR (Next one/third 8X16) OR (Next one/fourth 8X20) …

How do I query

This: Central satellite system price extraction script

Thanks

How do you determine if the product is “available”?

stock with

=stock=|
| 0 |
| 1 |
| 0 |
| 1 |

1 have in stock
0 don’t have stock

Presence or absence of 2 options

So… You should be able to simply query the next available using something like

SELECT `input_x_output` FROM `myTable` WHERE `stock` = '1' ORDER BY `input_x_output` ASC

No?

Thank you very much for your help

present the data from the first posting.

$input_output=$_POST[‘input_output’];

echo $input_output;

Sample:
Output: 8X12

Thanks

If you don’t mind me asking, but what’s this for? maybe there’s a better way of doing this.

But, you can also do what matt suggested, but more like
[php]
$qry = mysql_query("SELECT input_x_output FROM myTable")

if(mysql_num_rows($qry) != 0) {
while($r = mysql_fetch_array($qry)) {
$s = $r[‘input_x_output’];
if($s == ‘8x8’) {
$in = ‘Yes’;
} else {
$out[“8x8”] = “Yes”;
}
// repeat with other types
}

foreach($out as $val => $stock) {
echo “$out => $stock”;
}
}[/php]
That should tell you which ones are missing based on what you’ve given us.

Taking price online central satellite dish system for apartments is script.
http://dijitaluydu.info/sistem.GIF

I want to make a query:
Sample: $_POST with “8X12”
Conditions: 1. Brand 2. Types (Finite)
If there is, give 8x12
If there is no, give 8x16 next
If there is no 8x16, give 8x20 next
If there is no 8x20, give 8x24 next
If there is no 8x24, give 8x32 next
If there is no 8x32, “There is no product in stock”

These are standart.
output
8, 12, 16, 20, 24, and 32
input
8, 9, 10, 14, and 17

Thanks

I give up, have fun m@tt.

I’ll take one more shot at this. You are really hurting yourself by storing the input_x_output as a string. This should be two separate integer fields input and output. Then you would be able to do the sorting with MySQL.

However, here is my solution using strings:

[php]
$target = ‘8X8’; // the target input_x_output value
$products = array(); // store products from database

// query products
$sql = mysql_query("SELECT input_x_output, stock FROM table");
while($row = mysql_fetch_assoc($sql)) {
list($input, $output) = explode(‘X’, $row[‘input_x_output’]); // explode input output values
$products[(int) $input][(int) $output] = (int) $row[‘stock’]; // build array converting all strings to integers
}

// using a string in your database means we need to properly order the products
ksort($products, SORT_NUMERIC); // sort inputs by key
foreach($products as $input => $outputs) {
ksort($products[$input], SORT_NUMERIC); // sort outputs for each input by key
}

$product = null; // default value for product
list($target_input, $target_output) = explode(‘X’, $target); // explode target input output values

// find next available product for $target
foreach($products as $input => $outputs) {
if ($input < (int) $target_input) {
continue; // skip any products less than target_input
}
foreach($outputs as $output => $stock) {
if ($output < (int) $target_output) {
continue; // skip any products less than target_output
}
// this is the first product in stock with an input and output greater than or equal to the target
if ($stock === 1) {
$product = $input . ‘X’ . $output; // set the next available input_x_output
break 2; // stop the loops to keep $product from be overwritten
}
}
}

// no product was found if $product is null
echo ($product ? $product : “There is no product in stock”);
[/php]

Thank you very much for your help

No problem now that I’ve done with separate input and output

Best Regards

need to change the code?

I Changed The database table

Please help last

Best Regards
Thank you

Now that you have a proper table structure, you could simply query like so:

SELECT `input`, `output` FROM `table` WHERE `input` >= 8 AND `output` >= 8 AND `stock` = 1 ORDER BY `input` ASC, `output` ASC LIMIT 1

@m@tt your and everyone, thank you very very very very much
has worked

Greetings and best regards from Turkey

Adem GENÇ

Sponsor our Newsletter | Privacy Policy | Terms of Service