Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

310
Vistas
How to render specific view after clicking specific button. PHP HTML JS

I am making a page with soccer teams and leauges. Now i`m printing all Leagues that i want from the database.

League 1
League 2
League 3
etc.

As you can see each League has its own League_ID. In Database i also have a table of all teams, and each team has matched League (with League_ID). I also have a view, where i can print table of League that i want. This function in php looks like this.

public function leauge_table(){
    $tables = $this->scoreTableRepository
                    ->getScoreTable(1); 
    //TODO how to change this "1" static to generated
    //TODO when pressing link
    return $this->render('leauge_table', ['table' => $tables]);

And as you can see, when i go to this page i will always see the score table from leauge that has id=1.

And the question is how can i make that when i press for example at "League 2" i will open page but with table matching to League_ID = 2. Shall it be <button></button> or <a></a> in HTML. And how to pass there League_ID so my php back will see which table should render. Thank you really for help.

PS Or maybe do i have to make a seperate view for each leauge score table? And then just simply make buttons direct to these views with simple JS code. But would like to avoid it if it`s possible.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

In your SoccerTeam page add a button in a form with the following :

<form action="youpage.php" method="post">
<input name="leagueId" type="hidden" value="<?php echo $leagueId;?>" >
</form>

And in order to process that information, since we passed an id, we can retrieve it with $_POST['leagueId'] and because it's a POST request it wont be visible in the url:

$leagueId = $_POST['leagueId'];
over 4 years ago · Santiago Trujillo Denunciar

0

It can be a link or a button. A link with the league ID as a parameter in the URL is the simplest approach though, if you're new to the concept. e.g.

<a href="showleague.php?id=1">League 1</a>

The ID would then be available in the php script via $_GET["id], once the link is clicked.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda