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 5934707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:09:04+00:00 2026-05-22T15:09:04+00:00

I am very new to ajax and jquery but I know some php. I

  • 0

I am very new to ajax and jquery but I know some php. I have got a page where i get students detail. All i want is when i click add button that student will be inserted into paid table and that students name will show up on the page. There will be a delete button next to student`s name and it should delete the student if i click on it.

will it be hard to do this? Do you
know any samples on internet?

How should my ajax code be according to my pages?

this is my student page

<?
include ("connect.php");

$id = trim($_GET['id']);

 $result = mysql_query("SELECT * FROM students
 WHERE students_id='$id'");
 while($row = mysql_fetch_array($result))
 {
 $studentname = $row['students_name'];
 }

?>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
</head>

<body>

        <form method="post" name="form">
            <input type="hidden" id="studentname" name="studentname" value="<? echo $studentname; ?>" />
            <input type="submit" id="addme" name="addme" value="Add <? echo $studentname; ?>" />
        </form>


</body>
</html>

this is my add page

<?
include ("connect.php");

if (isset($_POST['addme'])) 
{

 $studentname = $_POST["studentname"];

 mysql_query("INSERT INTO paid SET paid_name = '$studentname'");

 mysql_close($con);

}
?>

This is my delete page

<?
include ("connect.php");

  $delete = $_POST["delete"];

  mysql_query("DELETE FROM paid WHERE paid_id='$delete'");
  mysql_close($con);

?>

This is my show page:

<?

include ("connect.php");

  $result = mysql_query("SELECT * FROM paid");
  while($row = mysql_fetch_array($result))
   {
   echo $row['paid_name'];
   echo "<br>";
   }

  mysql_close($con);



?>

This is my database:

--
-- Table structure for table `students`
--

CREATE TABLE IF NOT EXISTS `students` (
  `students_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `students_name` varchar(100) NOT NULL DEFAULT '',
  PRIMARY KEY (`students_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

-- 
-- Dumping data for table `students`
-- 

INSERT INTO `students` VALUES (1, 'David');
INSERT INTO `students` VALUES (2, 'Lisa');
INSERT INTO `students` VALUES (3, 'Jack');
INSERT INTO `students` VALUES (4, 'Michelle');


CREATE TABLE IF NOT EXISTS `paid` (
  `paid_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `paid_name` varchar(100) NOT NULL DEFAULT '',
  PRIMARY KEY (`paid_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

-- 
-- Dumping data for table `paid`
-- 

INSERT INTO `paid` VALUES (1, 'Michelle');
INSERT INTO `paid` VALUES (2, 'Lisa');

UPDATED#### Added my pages.

  • 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-22T15:09:05+00:00Added an answer on May 22, 2026 at 3:09 pm

    I think it would be easiest making all the functions in PHP first. Then adding jQuery/Ajax/Js on top.

    However, if you still want to do it this way, I recommend reading this: http://api.jquery.com/jQuery.ajax/

    Then I’d make three pages:

    1. Index (The main page)
    2. Add student page (Called using ajax, so no design needed)
    3. Delete student page (Also called using ajax, so no design needed)

    Then I’d have the add_student and the delete_student page take either POST or GET arguments.

    You will also need 2 JS functions:

    1. Delete student, takes the argument student_id, then calls the delete_student page with either POST or GET, through jQuery+ajax
    2. Create student, same as the above but with creating it instead.

    Also, you’d need to use jQuery to add/delete the user from the page (Not only in the database), otherwise you’d have to update the page all the time.

    Does this make sense?

    Otherwise, feel free to ask! 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to ajax and jquery, but I came across a code
I'm very very new to PHP, but now I have to help my friend
Very new to JQuery and MVC and webdevelopment over all. I'm now trying to
I'm very new to jQuery, Ajax and things like these. I've found solutions on
I am new to Ajax and have been following a tutorial from JQuery.com. I
I'm very new to jQuery and I'm writing some validation logic on a form.
I am a very new beginner and have been reading the help forums. All
So I am very new to using jQuery and I have a script that
I am very new to jQuery, and I am probably doing this wrong, but
I am very new to ajax concept,I want to submit a form without refresh

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.