0

I have a php for loop and inside the php for loop there is a button element inside a td tag. I am passing button Id from one page to another using query String.

page 1:

 $id = $data['no'];
<td><button class="btn btn-primary btn-small"><a href="votingPoll.php?'.$str.'">SUBMIT</a></button></td>

To get the value of the button id i have this code in page 2:

$id = $_GET['str'];

but for some reason it's giving me a error of undefined variable 'str' on page 2.

asked Feb 12, 2018 at 21:43
1
  • In page 1 add var_dump($str); and update your question with the output. Commented Feb 12, 2018 at 21:48

1 Answer 1

1

change your code to:

<td><button class="btn btn-primary btn-small"><a href="votingPoll.php?id='.$id .'">SUBMIT</a></button></td>

on yourpage.php or whichever file you would like to recieve the data, access it with $_GET['id']

answered Feb 12, 2018 at 21:46

3 Comments

Thank you, Can you all explain how to send multiple values in query string
multiple id's? or different data types?
multiple id's i think so.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.