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

  • Home
  • SEARCH
  • 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 7612703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:58:49+00:00 2026-05-31T01:58:49+00:00

I have made a question database with id . Now i am using ajax

  • 0

I have made a question database with id . Now i am using ajax to access the mysql database question one by one using First Next Previous Last button. How to do it. Here is my code.

index.php

<html>
<head>
<script type="text/javascript">
var str;
function showid(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;

    }
  }
xmlhttp.open("GET","request.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body onLoad="showid(1)">

<br />
<div id="txtHint">Requested Data
</div>
<br />

<input type="button" value="Last" name="First" onClick="showid(1)"  />
<input type="button" value="Previous" name="Previous" onClick="showid(2)"  />
<input type="button" value=Next name="Next" onClick="showid(3)"  />
<input type="button" value="First" name="Last" id="Last" onClick="showid(4)"  />


</body>
</html>

requesting page

<?php
$q=$_GET["q"];

$con = mysql_connect("localhost", "root", "");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("dbase", $con);

$sql="SELECT * FROM table WHERE id = '".$q."'";

$result = mysql_query($sql);

while($row = mysql_fetch_array($result))
  {
  $id=$row['id'];
  }
mysql_close($con);



?>
  • 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-05-31T01:58:50+00:00Added an answer on May 31, 2026 at 1:58 am

    Try using javascript to set the current question number and work from there.

    <script type="text/javascript">
    var str;
    var current_question = 1;
    function showQuestion(_direction)
    {
    if(_direction == 'prev') current_question--;
    else if(_direction == 'next') current_question++;
    else if(_direction == 'first') current_question = 1;
    else if(_direction == 'last') current_question = ?; // use php to set this when producing page
    //...
    xmlhttp.open("GET","question.php?q="+current_question,true);
    xmlhttp.send();
    

    then change your inputs like so

    <input type="button" value="|<" name="First" onClick="showQuestion('first')"  />
    <input type="button" value="<" name="Previous" onClick="showQuestion('prev')"  />
    <input type="button" value=">" name="Next" onClick="showQuestion('next')"  />
    <input type="button" value=">|" name="Last" id="Last" onClick="showQuestion('last')"  />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a similar question a few days ago, but now I have new
More of a design/conceptual question. At work the decision was made to have our
Coming from this question , I have a wxComboCtrl with a custom popup made
Question for YUI experts... I have a table and I've made each cell of
I started out with Django some days ago and I have now made a
In a previous question i made Dynamic dependent select menus i posted this example
I have another SQL/access 2007 question that seems really basic but I'm not sure
I have an embarrassing question regarding Access. I can build relational databases in my
Hey guys, I'm just starting out with MySQL and PHP and have a question.
Suppose I have a table in my database that is made up of the

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.