Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Call Textfield Input In Mysql Query

Junior Spellweaver
Joined
Apr 5, 2012
Messages
113
Reaction score
8
Dear Otaku

I wanted to ask you the following thing...

A div box looks like this:

Code:
Comments  
------------------  
Article 1
Article 2
Article 3
Article 4
Article 5
------------------
Show more comments

above that div box there is this input:

Code:
<input id="streamcntw" name="streamcntw" type="hidden" value="5">

The value of the input adds +5 to itself by clicking on "Show more comments" in the div box.
The problem is i don't know how to put that changeable value of the hidden input in the mysql query:

PHP:
 $comments = mysql_query("SELECT * FROM commentsnewsevents WHERE article = '$id' ORDER BY tstamp DESC LIMIT ???") or die(mysql_error());

I thought it would be simply $streamcntw (there where i wrote "???") but this leads into a sql error. I think the solution would be a form where i can cleantag($_POST['getmorecomments']) it but i don't know how to do this too without reloading the whole page.


I appreciate any help.


Greetings moere
 
Joined
Aug 4, 2010
Messages
572
Reaction score
177
Has Ajax is just an extended language to previous Javascript and such you can use Javascript to have the page auto refreshed or a certain DIV in this occasion would be you're auto updating feed.

That is if you know how to do it...
 
Junior Spellweaver
Joined
Apr 5, 2012
Messages
113
Reaction score
8
Can't someone help ;(? Here is the link to it =>

Register and go to an article. I made the hidden input box viewable for developement.

Please Please help

And yes i know i should use jquery or ajax but how is there a basic code that i could modify to make it work on my site ;(?
 
Joined
Jun 23, 2010
Messages
2,323
Reaction score
2,195
Assuming that "Show more comments" is a link.

Javascript action:
PHP:
function getMoreComments() {
var amount = $('#streamcntw').val();
$.ajax({
  url: "ajax/comment.php?aid=" + $('#articleid').val() + "&amount=" + amount
}).done(function(html) {
  $("#comments").append(html);
});
$('#streamcntw').val(amount + 5);
}

Code:
<a href="#comments" onclick="getMoreComments()">Show more comments</a>


And for the php side would be something like this:
 
Last edited:
Back
Top