Hi,
I have a php script which calls messages from a database but I'd like to allow people to make a comments on the messages and view old comments by selecting a button which will expand to show all the comments made on a specific message:
Code to retrieve messages:
I've attempted this using a JS function which expands when selecting the "show all" button (i hard coded a message id to do this) but I don't seem to be able to merge the messages and the comments together.
Does any one know how to easily do this?
Thanks in advance!
I have a php script which calls messages from a database but I'd like to allow people to make a comments on the messages and view old comments by selecting a button which will expand to show all the comments made on a specific message:
Code to retrieve messages:
Code:
$query1=mysql_query("select * from message order by timestamp desc" . " LIMIT $offset, $rowsPerPage");
//echo $today;
while ($row =@ mysql_fetch_array($query1)) {
echo "<tr><td>";
echo $row['message'];
echo "</td><td>";
echo "<tr><td>";
echo $row['name'];
echo "</td><td>";
echo "<tr><td>";
echo $row['timestamp'];
echo "</td><td>";
echo "<tr><td>";
echo "<tr><td>.......................</td><td>";
$messageid = $row['id'];
I've attempted this using a JS function which expands when selecting the "show all" button (i hard coded a message id to do this) but I don't seem to be able to merge the messages and the comments together.
Code:
<script type="text/javascript">
function toggleMe(obj, a){
var e=document.getElementById(a);
if(!e)return true;
if(e.style.display=="none"){
e.style.display="block"
obj.firstChild.data='Hide all';
} else {
e.style.display="none"
obj.firstChild.data='Show all';
}
return true;
}
</script>
<div id="showhide1" style="display: none;">
$query1=mysql_query("SELECT comment, name, timestamp FROM comments WHERE id=$messageid");
while ($row =@ mysql_fetch_array($query1)) {
echo "<tr><td>";
echo $row['message'];
echo "</td><td>";
echo "<tr><td>";
echo $row['name'];
echo "</td><td>";
echo "<tr><td>";
echo $row['timestamp'];
echo "</td><td>";
echo "<tr><td>";
echo "<tr><td>.......................</td><td>";
}
?>
<form name="update" action="insert_comment.php" method="post">
<table>
<tr>
<td> Comment: </td>
<td><textarea rows="2" cols="30" name="message" onchange="this.value=validated(this.value)"></textarea></td>
</tr>
<tr>
<td>Name:</td>
<td><input name="name" type="text" onchange="this.value=validated(this.value)" /></td>
</tr>
<tr>
<td><input name="add_button" type="submit" value="Update" /></td>
</tr>
</table>
</form>
</div>
<a href="#" onclick="return toggleMe(this, 'showhide1')">Show all</a>
Does any one know how to easily do this?
Thanks in advance!