Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8084171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:42:27+00:00 2026-06-05T17:42:27+00:00

I want to increment $x in this function to get next record in table.

  • 0

I want to increment $x in this function to get next record in table. But it is incrementing only once . Any Help is appreciated

This is the function I call,

<script type="text/javascript">
    function getnextques(){
        document.getElementById("quescontent").innerHTML= '<?php
        $x++;
        $res = mysql_query("SELECT * FROM question_content WHERE id=".$x) or die(mysql_error());  
        while($row=mysql_fetch_array($res)){
            echo $row['ques'] ;
        }; 
        ?>'
}
</script>

from ,

<a href="javascript:getnextques()" class="startbutton" id="mediumone"> Next </a>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:42:28+00:00Added an answer on June 5, 2026 at 5:42 pm

    you cannot mix like that Javascript with PHP. PHP is server side based, javascript is browser based.

    You should use Ajax for that (jQuery)

    eg:

    <script type="text/javascript">
    var x = 0;
    function getnextques(){
        var newX = x++;
        $.ajax({
            type: "POST",
            url: 'script.php',
            data: { x: newX },
            success: function(data) {
                document.getElementById("quescontent").innerHTML = data;
            }
        });
    }
    </script>
    

    and script.php

    <?php
        // mysql connection
        $x = (int) $_POST['x'];
        $res = mysql_query("SELECT * FROM question_content WHERE id=".$x) or die(mysql_error());  
        while($row=mysql_fetch_array($res)){
            echo $row['ques'] ;
        }
     ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a particular function I want to run once, and only after the
I want to increment id by 1 but I there is a problem while
I want to create a function which returns a temporary table of dates, for
I want increment #hidtr value in jquery. <script type=text/javascript> $('#hidtr').val(parseInt($('#hidtr').val()+1)); alert($('#hidtr').val()); </script>
i want to increment the value in database on each call. ie how to
I want to increment the value of i . The for loop does not
Possible Duplicate: ++ operator in Scala I want to increment an Int variable in
I am currently building a webshop for my own where I want to increment
I want to search person by auto increment ID (textbox and one button) .
I want to write a stored procedure to increment the value of an int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.