2014-12-29 34 views
0

在這段代碼中,當使用Google doc文件生成表單時,我們希望單獨提交所有按鈕,但是這樣我們就會形成分離提交按鈕... .................................................. .................................................. .................................................. .................................................. .................................................. ************************************************** ************************************************** ************************************************** ************************************************** ***我該如何給出一個提交生成許多按鈕的表單提交的常見按鈕

 $url='https://docs.google.com/xxxxxxxxxxxxxxxxxx'; 
    $cat =''; 
      if (($handle = fopen($url, "r")) !== FALSE) 
      { 
       while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) 
       { 
        $totalrows = count($data); 
        for ($row=0; $row<=$totalrows; $row++) 
        { 

         if (($row % 6 == 0) && (strlen($data[$row])>0)) 
         { 
         $answer = $row + 1; 

         $response["status"] = 1; 

         $response["price"] = $data[$answer+4]; 

         $prodname = explode(' ',$response["prodname"]); 
         $prodname = $prodname[0]; 
         if($_COOKIE[$prodname]) { $quantity = $_COOKIE[$prodname]; } else {  $quantity = "0"; } 


         if($response["subcat"] != 'Sub Category') 
         { 
          if($cat != $response["subcat"]){ 




           echo '</div>'; 
           echo '<div data-role="collapsible" data-collapsed-icon="arrow-r" data-expanded-icon="arrow-d" data-content-theme="c">'; 
           echo '<h3>'.$response["subcat"].'</h3>'; 
           echo '<div class="ui-grid-a"><div class="ui-block- a">'.$response["prodname"].' ('.$response["prodnamemarathi"].') - '.$response["quantity"].'<br/>Available in '.$month.'<br/>MRP: Rs.'.$response["price"].'</div> 
           <div class="ui-block-b"> 
           <form action="?user='.$user.'" method="post"><input type="number" name="quantity" data-mini="true" value="'.$quantity.'" /> 



           <input type="hidden" name="subcat" value="'.$response["subcat"].'"> 

           <input type="hidden" name="price" value="'.$response["price"].'"> 
           <input type="submit" value="Submit"></form></div></div>'; 


           $cat = $response["subcat"]; 
          } 
          else { 
           echo '<br/><div class="ui-grid-a"><div class="ui-block- a">'.$response["prodname"].' ('.$response["prodnamemarathi"].') - '.$response["quantity"].'<br/>Available in '.$month.'<br/>MRP: Rs.'.$response["price"].'</div> 
           <div class="ui-block-b"> 
           <form action="?user='.$user.'" method="post"><input type="number" name="quantity" data-mini="true" value="'.$quantity.'"/><input type="hidden" name="subcat" value="'.$response["subcat"].'"> 
           <input type="hidden" name="prodname" value="'.$response["prodname"].'"> 
           <input type="hidden" name="prodnamemarathi" value="'.$response["prodnamemarathi"].'"> 
           <input type="hidden" name="price" value="'.$response["price"].'"> 
           <input type="submit" value="Submit"> 
           </form></div></div>'; 

          } 
         } 

         } 
        } 
       } 


       fclose($handle); 
      } 
      echo '</div>'; 

?>

給出一些細節

+0

您需要添加更多的細節。是否所有按鈕都需要鏈接到相同的URL?他們都有相同的價值觀嗎?他們都需要提交相同的數據字段嗎?你有使用Javascript的選項嗎? –

+0

你的問題並不是真的關於PHP。這是關於HTML的。 PHP恰好是您用來生成HTML的代碼,但您可以輕鬆地使用Ruby或Perl,或者直接編寫靜態HTML,並且問題也會適用。 –

回答

0

生成一次表格,並將文本輸入放到循環中。給他們一個數組式的名字。

<form action="page2" method="post"> 
    <?php 
    while ($i <= 5): 
     ?> <input type="text" name="size[]"> 
    <?php endwhile; ?> 
    <input type="submit" name="submit" value="Review Order"> 
</form> 

page2,可以訪問$_POST['size']作爲陣列,其中將包含所有的輸入。

+0

兄弟我有一個PHP代碼,我得到了很多問題,你能幫我嗎 – user3809212