2011-01-21 33 views
0

これはちょっと私がここでそれを渡すと思ったので、この1つにスタックされています。残りを使用して入力を選択してください

私はダイナミックにy軸、x軸、および値のボックスを入れて作成することができます。

値の入力ボックスの名前は、左から右、上から下に番号が付けられています。

0,1 
2,3 
4,5 
6,7 

入力ボックス7では、値を入力してX軸とY軸のタイトルを取得したいとします。フォームは、アレイが構築されることによってsummbitedさ

[heading_x] => Array 
    (
     [0] => red 
     [1] => black 
    ) 

[heading_y] => Array 
    (
     [0] => Small 
     [1] => Medium 
     [2] => Large 
     [3] => X-Large 
    ) 

[value] => Array 
    (
     [1] => Array 
      (
       [0] => 
       [1] => 
      ) 

     [2] => Array 
      (
       [0] => 
       [1] => 
      ) 

     [3] => Array 
      (
       [0] => 
       [1] => 
      ) 

     [4] => Array 
      (
       [0] => 
       [1] => foo 
      ) 

私は、xとy軸を見つけるために、これまでに書いたコードは

$max = count($options['heading_x']); 
$base = $match[2] + 1; 
$position_x = ($base % $max) + 1; 
$position_y = ((floor($base/$max) - 1) < 0 ? 0 : floor($base/$max) - 1); 

posiitionのyは、メインビットは大丈夫であるように思わ

if(preg_match("#^([0-9]+)\-value([0-9]+)\-([0-9]?)$#is", $key, $match)) { 
       foreach($attrDetails as $key_2 => $array) { 
        if($array['attribute_id'] == $match[1] && $val != '0' && $val != '') { 
         $options = unserialize(stripslashes($attrDetails[$key_2]['attribute_options'])); 
         unset($options['value'][0]); 
         print_r($options); 
         $max = count($options['heading_x']); 
         $base = $match[2] + 1; 
         $position_x = ($base % $max) + 1; 
         $position_y = ((floor($base/$max) - 1) < 0 ? 0 : floor($base/$max) - 1); 
         if($match[3] == '' || $base == '0') { 
          if($pd_details->pd_activate_special_offer == '1' && $pd_details->pd_offer_price != '0.00') { 
           if($array['attribute_type'] == '4') { 
            $cost = $val * $pd_details->pd_offer_price; 
           } 
          }else{ 
           if($array['attribute_type'] == '4') { 
            $cost = sprintf("%01.2f", $val * $pd_details->pd_price); 
           } 
          } 
         } 
         die($position_x . '/' . $position_y); 
         echo $options['heading_y'][$position_y-1] . '/' . $options['heading_x'][$position_x-1] . " amount: $val cost: $cost <br />\n"; 
         $_SESSION['basket']['items']['top_option'][] = $options['heading_x'][$position_x-1]; 
         $_SESSION['basket']['items']['side_option'][] = $options['heading_y'][$position_y-1]; 
         $_SESSION['basket']['items']['amount'][] = $val; 
         $_SESSION['basket']['items']['price'][] = $cost; 
        } 
       } 
      } 

以下の通りです。 。私の問題点が

階($ベース/ $最大)言うことができます - 1

= 3.50。

私は3が3番目のダウン(またはキー3が忘れてしまった)であることを知っています。どのように残りの部分を使ってx軸を見つけることができますか?

答えて

1

用事...

$max = count($options['heading_x']); 
$position_x=0; 
$position_y=0; 
for($z=0; $z<$match[2]+1; $z++){ 
    if($position_x % $max == 0) { $position_y++; $position_x=0; } 
    $position_x++;        
} 
+0

あなたがあなた自身の質問に答えてきたので、「受け入れられた」として、それはunanaswered質問の一覧に表示されないように、答えをマークしてください。ありがとうございました。これは、将来このページを見つけて同じ質問に対する回答を探している人にも役立ちます。 – Spudley

関連する問題