Reply function solution

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.