Perad Posted September 28, 2007 Share Posted September 28, 2007 I want to select the first item of the post array. How do i do it? Quote Link to comment https://forums.phpfreaks.com/topic/71084-selecting-_post0/ Share on other sites More sharing options...
MadTechie Posted September 28, 2007 Share Posted September 28, 2007 maybe echo current($_POST); not sure what you mean by select it ! Quote Link to comment https://forums.phpfreaks.com/topic/71084-selecting-_post0/#findComment-357423 Share on other sites More sharing options...
Perad Posted September 28, 2007 Author Share Posted September 28, 2007 I mean that I want to gather only one $_POST item and that is the first post item so I can use it later on in my script. Quote Link to comment https://forums.phpfreaks.com/topic/71084-selecting-_post0/#findComment-357425 Share on other sites More sharing options...
MadTechie Posted September 28, 2007 Share Posted September 28, 2007 i'm sorry i am still not sure what your trying to do. basic example! <form method="post"> <input name="test1" type="text"><br> <input name="test2" type="text"><br> <input name="test3" type="text"><br> <input name="test4" type="text"><br> </form> <?php $t1 = $_POST['test1']; $t2 = $_POST['test2']; $t3 = $_POST['test3']; echo "$t1, $t3, $t3, etc"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/71084-selecting-_post0/#findComment-357432 Share on other sites More sharing options...
Perad Posted September 28, 2007 Author Share Posted September 28, 2007 for ($i=0;$i<=count($item)-1;$i++) { <input type=\"submit\" class=\"select\" name=\"$item[$i]\" value=\"\"> } Multiple forms... each submit button has a different name. Name is based on the item code and thus I do not know it. Only one submit button can be pressed. Because I cannot put in $_POST['name'] I need to be able to sign the first value in the $_POST array to a variable. I tried $_POST[0] but it didn't work. furthermore current($_POST) also didn't work. Quote Link to comment https://forums.phpfreaks.com/topic/71084-selecting-_post0/#findComment-357434 Share on other sites More sharing options...
sasa Posted September 28, 2007 Share Posted September 28, 2007 try <form method="POST"> <input type="submit" name="name1" value="Click me" /> <input type="submit" name="name2" value="Click me" /> <input type="submit" name="name3" value="Click me" /> <input type="submit" name="name4" value="Click me" /> </form> <?php $post_fliped=array_flip($_POST); echo $post_fliped['Click me']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/71084-selecting-_post0/#findComment-357457 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.