Show data and click on it to open

Asked

Viewed 213 times

1

I have a question. I’m doing a job where I have a page that shows the name of a club.

 while($exibe = mysql_fetch_array($qr)){

 echo '<p><h2>'.$exibe['Nome'].'</h2></p>';
 }

And I want you to click the name or a button in front to show me all the information of this club on another page.

 while($exibe = mysql_fetch_array($qr)){

 echo'<div id="tabs-1">
 <img align="right" src="logos/'.$exibe["Nome"].'.jpg">
       <p>Nome:<b>'.$exibe["Nome"].'</b></p>
       <p>Morada:   '.$exibe["Morada"].'</p>
       <p>Distrito: '.$exibe["Distrito"].'</p>
       <p>Concelho: '.$exibe["Concelho"].'</p>
  • Just so I understand what you want, something like that would be enough?

  • I want the data to appear in the second while. For example: I click on the name "A" and then show me the data I chose in the second page

2 answers

2

If you want to redirect the information by clicking on the name you must create a for such a page passing some identification. We will say that your page that will receive the information after clicking on the link is called outrapagina.php and wanted to search for the id the data, just put it like this outrapagina.php?id= and its code

while($exibe = mysql_fetch_array($qr))
{
 echo '<p><h2><a href="outrapagina.php?id='.$exibe['id'].'">'.$exibe['Nome'].'</a></h2></p>';
}
  • But I’m having a problem. I have two dice with the one you gave me. E by clicking on the first one show me both . When I should only show the first

  • @user3253195, as you planned your table, it has a line identifier, a key Primary?

  • meto Where id=?

  • outrapagina.php?id='.$exibe['id'].' if you have the field with the id name yes or code there will depend on your table, and on the other page you have to rescue this id and use in sql

2

You should create a redirect to another page and filter in your database with the id of the previous page.

while($exibe = mysql_fetch_array($qr))
{
 echo '<p><h2><a href="outrapagina.php?id='.$exibe['id'].'">'.$exibe['Nome'].'</a></h2></p>';
}

this you put on your main page, and in other page.php, you must redeem the id passed by the previous page

// resgata o id passado por url
$id = $_GET['id'];

//filtra os dados conforme o id;
$sql = mysql_query("select * from SUABASE where id = $id;");
$exibe = mysql_fetch_array($sql);

echo'<div id="tabs-1">
 <img align="right" src="logos/'.$exibe["Nome"].'.jpg">
       <p>Nome:<b>'.$exibe["Nome"].'</b></p>
       <p>Morada:   '.$exibe["Morada"].'</p>
       <p>Distrito: '.$exibe["Distrito"].'</p>
       <p>Concelho: '.$exibe["Concelho"].'</p>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.