Mikkel Petersen Mikkel Petersen - 5 months ago 10
PHP Question

Load page depending on what the value of ?id=something in the url

So I want to load for example:

<center>
<h3>What comes after 6?</h3>

<form action="">
<select name="answerone">
<option value="0">Please select a number</option>
<option value="3">3</option>
<option value="7">7</option>
<option value="4">4</option>
<option value="8">8</option>
</select>
<h3>What comes after 2?</h3>
<select name="answertwo">
<option value="0">Please select a number</option>
<option value="3">3</option>
<option value="7">7</option>
<option value="4">4</option>
<option value="8">8</option>
</select>
<h3>What comes after 7?</h3>
<select name="answertwo">
<option value="0">Please select a number</option>
<option value="3">3</option>
<option value="7">7</option>
<option value="4">4</option>
<option value="8">8</option>
</select>
</form>
</center>


if the url is http://eduhub.dk/en/math/Counting/assignment?id=1
but if it's http://eduhub.dk/en/math/Counting/assignment?id=2 I want it to disappear, how would I do that? I've tried a lot of things, but it won't work, and this was the last thing I wanted to do, because I don't want to look helpless... But in this case I am helpless.

Answer

You can access the id by $_GET['id']. Using that you can either use require_once to include that file into your page or if you store your data in the database, you can make a query.

Comments