Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript on click show/hide content
    text
    copied!<p>I'm trying to develop a private message system using php/mysql. </p> <p>I've got a database set up like this: </p> <pre><code>CREATE TABLE IF NOT EXISTS `messages` ( `messageID` int(25) NOT NULL AUTO_INCREMENT, `msgTo` varchar(24) NOT NULL, `msgFrom` varchar(24) NOT NULL, `subject` varchar(100) NOT NULL, `message` text NOT NULL, `sendTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`messageID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; </code></pre> <p>I list the messages sent to a specific username as follows: </p> <pre><code>&lt;?php $query = "SELECT * FROM messages WHERE msgTo = '$username'"; // I know SELECT * should be avoided but there's not many columns here anyway $result = mysql_query($query); while($messages = mysql_fetch_array($result)){ ?&gt; &lt;ul class='lbe_list'&gt; &lt;li&gt; &lt;a href=''&gt; &lt;?php echo "From: ".$messages['msgFrom']."&lt;/a&gt;&amp;nbsp;Subject: ".$messages['subject'];?&gt; &lt;/li&gt;&lt;/a&gt;&lt;/ul&gt; &lt;?php } </code></pre> <p>Which lists the sender and the subject of the message. </p> <p><strong>However, I want to be able to click the username and subject here, and use JavaScript to expand the window so it will list the message itself below. Like the following:</strong></p> <pre><code>&lt;a href=''&gt; &lt;?php echo "From: ".$messages['msgFrom']."&lt;/a&gt;&amp;nbsp;Subject: ".$messages['subject'];?&gt; &lt;/li&gt;&lt;/a&gt;&lt;/ul&gt; &lt;?php // on click expand/hide $messages['message']; ?&gt; </code></pre> <p>Any help will be appreciated</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload