2013-02-19 65 views
0

這是我的代碼的一部分,我將ID發送給url,並且需要獲取該ID。但問題是,我得到這樣的從PHP中的URL獲取多個具有相同名稱的參數

delete.x = 5 & delete.y = 8 &刪除=刪除& ID = 124 & ID = 125 & ID = 126 & ID = 127 & ID = 128 & ID = 129 & ID = 130 & ID = 131 & ID = 132 & ID = 133 & ID = 134 & ID = 135 & ID = 136

它從表中發送我所有的ID。但我需要發送一個ID,取決於我點擊哪個按鈕(刪除或發佈)

<tr> 
     <td>125</td> 
     <td>Blacksfeets Photos</td> 
     <td>[email protected]</td> 
     <td>2929610140-09 M plava.pdf</td> 
     <td>24</td> 
     <td>570099</td> 
     <td>0</td> 

     <td></td> 
     <td></td> 
     <td></td> 
     <td></td> 
     <td> 
     <input name="delete" type="image" src="images/delete.png" value="Delete"><br> 
     <input name="publish" type="image" src="images/publish.gif" value="Publish"> 
     <input type="hidden" value="125" name="ID"> 
     </td> 

    </tr>   
     <tr> 
     <td>126</td> 
     <td>TimeSince</td> 
     <td>[email protected]</td> 
     <td>25189210140-09 M plava.pdf</td> 
     <td>24</td> 
     <td>614227</td> 
     <td>0</td> 

     <td></td> 
     <td></td> 
     <td></td> 
     <td></td> 
     <td> 
     <input name="delete" type="image" src="images/delete.png" value="Delete"><br> 
     <input name="publish" type="image" src="images/publish.gif" value="Publish"> 
     <input type="hidden" value="126" name="ID"> 
     </td> 

    </tr>   
     <tr> 
     <td>127</td> 
     <td>TimeSince</td> 
     <td>[email protected]</td> 
     <td>21813910140-09 M plava.pdf</td> 
     <td>24</td> 
     <td>966462</td> 
     <td>0</td> 

     <td></td> 
     <td></td> 
     <td></td> 
     <td></td> 
     <td> 
     <input name="delete" type="image" src="images/delete.png" value="Delete"><br> 
     <input name="publish" type="image" src="images/publish.gif" value="Publish"> 
     <input type="hidden" value="127" name="ID"> 
     </td> 

    </tr>  
+1

的可能重複(http://stackoverflow.com/questions/353379/how-to-get-multiple-parameters-with-same [如何從PHP中的URL獲得與名稱相同的多個參數] -name-from-a-url-in-php) – geoffspear 2013-02-19 14:35:52

+0

但是有可能只發送一個ID而不是所有的ID,所以我不得不爆炸。所以我知道我需要哪個ID – FosAvance 2013-02-19 14:42:42

回答

1

您似乎對所有按鈕都有一種形式。每個ID使用一種形式,例如

<form method="get" action="whatever"> 
    <input name="delete" type="image" src="images/delete.png" value="Delete"><br> 
    <input name="publish" type="image" src="images/publish.gif" value="Publish"> 
    <input type="hidden" value="127" name="ID"> 
</form> 
相關問題