jopereira Posted March 1, 2013 Share Posted March 1, 2013 (edited) <?PHP $conn = mysql_connect("localhost", "root", "") or die("Impossivel conectar"); if($conn) { mysql_select_db("eventos", $conn); } $sql = "SELECT * from eventos where id_eventos=1"; $rs = mysql_query($sql, $conn); $num = mysql_num_rows($rs); if($num > 0) { echo "<table border=0 cellpadding=0 cellspacing=0>\n"; echo "<table border=0 cellpadding=3 cellspacing=0> <tr> <td>Nº de Evento</td> <td>Nome</td> <td>Descrição</td> <td>Requisitos</td> <td>Data</td> <td>Vencedor</td> </tr>"; while($dados = mysql_fetch_array($rs)) { $id = $dados["id_eventos"]; $nome = $dados["nome"]; $desc = $dados["descricao"]; $req = $dados["requisitos"]; $data = $dados["data"]; $vence = $dados["vencedor"]; //$img = $dados["imagens"]; echo" <tr>"; echo" <td>$id</td>"; echo" <td>$nome</td>"; echo" <td>$desc</td>"; echo" <td>$req</td>"; echo" <td>$data</td>"; echo" <td>$vence</td>"; echo "<td>"; echo"<a href=\"1.php?id=$id\/a>"; echo"</td>"; echo" </tr>\n"; } } echo "</table>\n"; ?> tenho este codigo, e lista todos os dados que tenho, e cada 1 tem 1 link, mas o link é igual para todos.. como faço para que em cada click, abra o registo correspondente? algum select pelo id ou qualquer coisa? ps: quando veem o select do id_eventos = 1 foi só para testar.. se dava erro até lá.. estes eu tinha lá "$id" Edited March 1, 2013 by jopereira Quote Link to comment https://forums.phpfreaks.com/topic/275094-select-e-listagem-de-dados-cada-um-com-link-diferente/ Share on other sites More sharing options...
jazzman1 Posted March 1, 2013 Share Posted March 1, 2013 You must write every mysql_* and php functions in your native language and everything should be just fine, without any errors! Quote Link to comment https://forums.phpfreaks.com/topic/275094-select-e-listagem-de-dados-cada-um-com-link-diferente/#findComment-1415869 Share on other sites More sharing options...
Barand Posted March 1, 2013 Share Posted March 1, 2013 (edited) if($num > 0) { echo "<table border=0 cellpadding=0 cellspacing=0>\n"; echo "<table border=0 cellpadding=3 cellspacing=0> . . . } echo "</table>"; 2 open table tags and one close table tag that is not echoed under the same conditions as table open Edited March 1, 2013 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/275094-select-e-listagem-de-dados-cada-um-com-link-diferente/#findComment-1415884 Share on other sites More sharing options...
jopereira Posted March 1, 2013 Author Share Posted March 1, 2013 sorry.. i forgot this was an inglish site.. my question is about the links of the listed "items" I've got 3 listed items, like this: Item one Item two Item three each one of this items have a link, but all the 3 items are different rows from the same table, but all the links open the same how can I distinct each one of the links? I got the code above, that is included in the index page, as you can see here: ... <div id="column2"> <h2>Artigos</h2> <ul class="list-style2"> <?php include "listar_evento.php" ?> </ul> <p><a href="#" class="link-style">Read More</a></p> </div> <div id="column3"> <h2>Em Destaque</h2> <p><img src="images/evento1.jpg" width="430" height="200" alt="" /></p> <p>Detalhes do evento publicados em breve.</p> <p><a href="#" class="link-style">Read More</a></p> </div> </div> </div> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/275094-select-e-listagem-de-dados-cada-um-com-link-diferente/#findComment-1415896 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.