Reply function: $ sqlselect & nbsp; * & nbsp; from & nbsp; massage & nbsp; where & nbsp; I; $ result $ db-& gt; que reply function
The reply content read from the database:
$ SQL = "select * from massage where iid = $ iid order by mid desc limit $ offset, $ pagesize ";
$ Result = $ db-> query ($ SQL );
While ($ row = $ result-> fetch_assoc ())! = False ){
Echo'
# '. $ Row ["mid"].' '. $ Row ["author"].' |
'. $ Row ["msg"].' Reply '. $ row ["time"].' |
';
}
Copy the content read above to textarea:
Script
Function toCopy (){
Var midval = document. getElementById ("mid"). innerHTML;
Var msg = document. getElementById ("msgten"). innerHTML;
Document. getElementById ("msgcon"). value = "reply" + midval + "" + "[" + msg + "]";
Document. getElementById ("msgcon"). focus ();
}
Script
Effect:
The problem is: the text box will always display the last one read by the database, that is, 13th. copy the one to which reply you want to copy it to the box.
------ Solution ----------------------
Id = "msgten"
Your id is repeated and cannot be used like this.
Modify it to look like this
$ SQL = "select * from massage where iid = $ iid order by mid desc limit $ offset, $ pagesize ";
$ Result = $ db-> query ($ SQL );
$ I = 0;
While ($ row = $ result-> fetch_assoc ())! = False ){
Echo'
# '. $ Row ["mid"].' '. $ Row ["author"].' |
'. $ Row ["msg"].' Reply '. $ row ["time"].' |
';
$ I ++;
}
Script
Function toCopy (c ){
Var midval = document. getElementById ("mid" + c). innerHTML;
Var msg = document. getElementById ("msgten" + c). innerHTML;
Document. getElementById ("msgcon"). value = "reply" + midval + "" + "[" + msg + "]";
Document. getElementById ("msgcon"). focus ();
}
Script