Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Sep 2010
    Location
    London, UK
    Posts
    167
    Thanks
    28
    Thanked 0 Times in 0 Posts

    A different kind of 'comment' script needed

    Having done a search on scripts and trying to find one that fits my criteria and not finding anything that I was looking for I am posting this to see if someone knows where to find this type of script or who could help me make one.

    What I looking for is a script that will post a comment that has just been typed into the webpage that the script is on, just above the comment box where one types it. What I would also like is for the comments to appear one after the other in the same place instead of having them all appear on one page. So instead of a whole page of comments the script will show the comments in rotation, first one, then another, then another, etc, and loop back to the first comment then do it again indefinitely.

    The comments need to be stored in a database (MySql) and retrieved then displayed for x amount of seconds based upon the number of characters and spaces in the comment. The transition of one comment to another would be a fade effect or scroll effect (upwards). I am also trying to stick to php without any javascipt.

    The server is an Apache server so can only do php not ASP.

    If anyone can help me on this it would be most appreciated.

  • #2
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Quote Originally Posted by judgedredd View Post
    The comments need to be stored in a database (MySql) and retrieved then displayed for x amount of seconds based upon the number of characters and spaces in the comment. The transition of one comment to another would be a fade effect or scroll effect (upwards). I am also trying to stick to php without any javascipt.
    It has to be Javascript.

    Also as a user I would find it annoying to half read a message and it scrolls to the next one. You should let the user click a next button.



    --
    Last edited by Len Whistler; 08-09-2012 at 08:04 PM.
    Leonard Whistler

  • #3
    Regular Coder
    Join Date
    Sep 2010
    Location
    London, UK
    Posts
    167
    Thanks
    28
    Thanked 0 Times in 0 Posts
    Ok. Your point is valid as I get annoyed too. So 'Next' button include.

    Can you explain why javascript would be needed? Is it because of the transition from one comment to another? Or some other reason?

    If there is now a 'Next' button all that would do is retrieve the next comment from the DB and display it.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    PHP is a server side language. Its incapable of providing rotating effects or animation.

    The entire behaviour you describe would be done using AJAX (which is just a JS technology) to communicate with PHP. PHP's job will be to accept the posting and write it to a database, as well as retrieve the comment. To create the next, all you do is use AJAX to poll both for the comment itself, as well as a link to the "next" comment.

  • #5
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Quote Originally Posted by judgedredd View Post
    Ok. Your point is valid as I get annoyed too. So 'Next' button include.

    Can you explain why javascript would be needed? Is it because of the transition from one comment to another? Or some other reason?

    Yes ..... Unless HTML 5 with CSS can do transitions. I'm not into HTML 5 yet.

    Quote Originally Posted by judgedredd View Post
    If there is now a 'Next' button all that would do is retrieve the next comment from the DB and display it.
    Yes .... And that's very easy with PHP.


    --
    Leonard Whistler

  • #6
    Regular Coder
    Join Date
    Sep 2010
    Location
    London, UK
    Posts
    167
    Thanks
    28
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    PHP is a server side language. Its incapable of providing rotating effects or animation.
    One could also use an opaque layer that transitions to transparent using css/html 5 I think.

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Maybe, but I don't do client side languages. All I can say is that PHP is incapable of doing this; it can only provide the data required to the client language to work with.

  • #8
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    721
    Thanks
    20
    Thanked 84 Times in 84 Posts
    you could have the next button reloading the same page with the next comment


    EDIT
    you would need to use page transition tho and not just the comment
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  • #9
    Senior Coder
    Join Date
    Sep 2010
    Posts
    2,089
    Thanks
    15
    Thanked 246 Times in 246 Posts
    Here's one way you could do this. Declare a javascript array. As each comment is entered push it into the array. You may have to omit or escape any double quotes or commas for the array to work. Then just have a little script that randomly selects elements of the array to display. As for saving them to a database you could put the array into a hidden input value and upload it in a form. But a JS array uploaded that way will be a comma separated list so it will have to be dealt with that way. Or you could format it as a long string with another separator like the | , my favorite for that since it isn't used for much else.

  • #10
    Regular Coder
    Join Date
    Sep 2010
    Location
    London, UK
    Posts
    167
    Thanks
    28
    Thanked 0 Times in 0 Posts
    Thank you everyone for your inputs. This is a bit beyond my capabilities at the moment as I am not java script-savvy.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •