Click on line in the table, to open new message?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Nimaro
Forum Newbie
Posts: 19
Joined: Thu Nov 19, 2009 11:26 am

Click on line in the table, to open new message?

Post by Nimaro »

hy everyone,
I have 1 table of messages that is create dinamicaly. What im trying to do now is when the user click on 1 line of the table("each line of the table represents 1 message"), the message open in a new window.
Im going to post my code here... i thing it helps always!

Code: Select all

<!----------------PESQUISA POR Medico---------->
<?php
if(isset($_POST['submit']))
{
$id_medico = strip_tags($_POST['id_medico']);
$exc = "SHOW TABLES"; /*VARIÁVEL RENOMEADA*/
$query = mysql_query("SELECT * FROM mensagens WHERE id_medico = '".mysql_real_escape_string($id_medico)."'");
?>
<div id="topic">
<b>Tabelas da base de dados</b>
</div>
<table id="content" border="2" bordercolor="#00CC00">
<tr>
<th>id_utilizador</th>
<th>mensagem</th>
<th>data</th>
<th>hora</th>
</tr>
<?php
while($dados = mysql_fetch_array($query)){
?>
<tr>
<td> <?php echo $dados[2]; ?></td>
<td>| <?php echo $dados[3]; ?></td>
<td>| <?php echo $dados[4]; ?></td>
<td>| <?php echo $dados[5]; ?></td>
</tr>
<?php } ?>
</table>
<?php
} else $nome = '';
?>
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Click on line in the table, to open new message?

Post by Christopher »

Use:

- the target="" parameter for the HTML link,
- Javascript window.open()
- show a hidden div as a popup layer
(#10850)
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Click on line in the table, to open new message?

Post by superdezign »

As for the click, give the table rows the CSS style "cursor: pointer" so that users know that they can click on it, and apply the JavaScript to open a new window at the onClick event.
Post Reply