How can I put two URL parameters in a php file?

Tags: , ,



My Tables:

Console

Genre

Game

I want to be able to first choose a console, then a genre, then having the games visible. Each table has its own “show…” PHP file. I use 1 URL parameter in the php-file “showconsole.php” to reference from console to genre, like this:

<a href='showgenre.php?idconsole=$id'>

The variable “$id” doesn’t get used yet, since all consoles all have the same game genre(This is not the problem). Still having the same URL Parameter, I want to add another one, but don’t know which symbol to use. This is what I tried inside “showgenre.php”:

<a href='showgame.php?idconsole=$id/idgenre=$id2'>

“/” doesn’t seem to do the job. How can I make a parameter that contain two URL parameters?

In “showgame.php”, I’ve putted this:

        if(isset($_GET["idconsole"])) {
        $id = $_GET["idconsole"];           
    } else {
        die("You need to choose a console.");
    }
    if(isset($_GET["idgenre"])) {
        $id2 = $_GET["idgenre"];            
    } else {
        die("You need to choose a genre.");
    }   

I also have another problem, where when I choose a genre in “showgenre.php”, it tells me that I need to chose a console as well, meaning…

if(isset($_GET[“idconsole”])) {

…isn’t working. How can I still have the console id with me when I go from genre to game? I want it to be like this(for example):

PS4 -> Choose a game-genre -> SHOWS ALL PS4 ACTION GAMES

Answer

Try using the ampersand ‘&’ instead of ‘/’ to use several parameters in url. Like this :

<a href='visspill.php?idconsole=$id&idgenre=$id2'>



Source: stackoverflow