0

I have an input box in index.php which takes some user input and queries a database using that input field as an attribute. This input is stored in $arrInput[0].

I also have a link to inspect.php which, when clicked, takes me to inspect.php but I need to pass $resultArr[0] to inspect.php so that I can use that variable to continue doing other things within inspect.php. How can I achieve this? \

Currently this is what I have:

/* inspect.php  */
// Create a table with some rows. Then create this 
// column which has the inspect link
echo "<td>  <a href='inspect.php?id=<?php echo $resultArr[0]; ?>'>Inspect</a>
              </td>";
...

But I don't know how to access $resultArr[0] within inspect.php. I was told $_GET[] would help, but I'm not sure how and googling the subject hasn't been much help.

Can anyone please help?

Thank you

2 Answers 2

1
echo "<td><a href='inspect.php?id=".$resultArr[0]."'>Inspect</a></td>";

I think you are using wrong syntax. Please check above code. You can the access 'id' key inside $_GET.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much. This fixed everything.
1

Not that hard. use $_GET['id'].

2 Comments

ah, dang faster than me, nice
I've been trying this but for some reason I can't display its value. This is what I have at the very top of inspect.php: <?php session_start(); if(isset($_GET['id']) && $_GET['id'] != '') { echo $_GET['id']; echo "yeah" } only "yeah" is getting displayed

Your Answer

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.