zppinto Posted August 15, 2012 at 05:44 PM Report Share #472363 Posted August 15, 2012 at 05:44 PM (edited) Boas, Estou com o problema na visualização dos resultados. O que estou a tentar fazer é imprimir todos os resultados com determinado "gameID", tendo em conta o video em causa "movie1", "movie2", etc. Mas não o consigo fazer de forma a que sejam apresentadas todas as tags correspondentes ao "movie2" seguidas, em vez do que acontece na figura seguinte, em que é apresentada cada tag, e cada video correspondente. A tabela em causa é esta: Alguém me poderia dar uma ajuda? Obrigado! <?php $con = mysql_connect("localhost","root","root"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("teste", $con); $var = ($_COOKIE['GameID']); $result = mysql_query("SELECT DISTINCT filename, tag FROM dados WHERE gameid = '$var'"); print "<h1 align=center>GAMEOVER</h1>"; while($info = mysql_fetch_array( $result )) { print "<table cellpadding='2' border='0' align='center' class='gmovbx'>"; print "<tbody><tr>"; print "<th class='gmovbx'>Videos</th>"; print "<th class='gmovbx'>Tags</th>"; print "</tr>"; print "<tr><td class='gmovbx'>"; print "<video src='vids/" .$info['filename'] ."' height='90' width='120'></td><td class='gmovbx' width='350'>" .$info['tag']. "</td>"; print "</tbody></table>"; //Print "<th>|</th> <td>".$info['tag'] . "</td> "; } mysql_close($con); ?> Edited August 15, 2012 at 06:01 PM by zppinto Link to comment Share on other sites More sharing options...
pmg Posted August 15, 2012 at 06:05 PM Report Share #472365 Posted August 15, 2012 at 06:05 PM (edited) Estou a ver que usas o MySQL. Usa o GROUP_CONCAT. Esta solucao nao é aplicavel a outras bases de dados. Talvez assim, nao testado: select filename, group_concat(tag) from dados where gameid = 251374 group by filename Edited August 15, 2012 at 06:08 PM by pmg What have you tried? Não respondo a dúvidas por PM A minha bola de cristal está para compor; deve ficar pronta para a semana. Torna os teus tópicos mais atractivos e legíveis usando a tag CODE para colorir o código! Link to comment Share on other sites More sharing options...
zppinto Posted August 15, 2012 at 06:13 PM Author Report Share #472366 Posted August 15, 2012 at 06:13 PM (edited) Parece que dá um erro no print da tag! Notice: Undefined index: tag in D:\Program Files\xampp\htdocs\Login&Registration\gameover.php on line 23 Edited August 15, 2012 at 06:14 PM by zppinto Link to comment Share on other sites More sharing options...
pmg Posted August 15, 2012 at 06:18 PM Report Share #472367 Posted August 15, 2012 at 06:18 PM Parece que dá um erro no print da tag! Entao da um nome a coluna ... select filename, group_concat(tag) as tag from dados where gameid = 251374 group by filename 1 Report What have you tried? Não respondo a dúvidas por PM A minha bola de cristal está para compor; deve ficar pronta para a semana. Torna os teus tópicos mais atractivos e legíveis usando a tag CODE para colorir o código! Link to comment Share on other sites More sharing options...
zppinto Posted August 15, 2012 at 06:41 PM Author Report Share #472369 Posted August 15, 2012 at 06:41 PM Muito obrigado pmg! 🙂 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now