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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:51:07+00:00 2026-05-29T23:51:07+00:00

i want to record a user inputed value and at the same time copy

  • 0

i want to record a user inputed value and at the same time copy a single data from another table. is it possible?

here is my code:

$sql="INSERT INTO grades (studentnumber,subjectcode)
VALUES
('$_POST[studentnumber]','$_POST[subjectcode]')";

$sql="INSERT INTO grades (course) SELECT course FROM students WHERE studentnumber= '$_POST[studentnumber]'";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "<script type='text/javascript'>alert('Record Successfully Added'); location.href = '../instructor/cvsu-sis_students.php';</script>";

thanks in advance and sorry for my elementary question.

  • 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-29T23:51:09+00:00Added an answer on May 29, 2026 at 11:51 pm

    You can do it in one query if that’s what you are asking about, also remember to escape the strings to avoid SQL Injection:

    $P_studentnumber=mysql_real_escape_string($_POST['studentnumber']);
    $P_subjectcode=mysql_real_escape_string($_POST['subjectcode']);
    
    $sql="INSERT INTO grades (studentnumber,subjectcode,course) SELECT '$P_studentnumber','$P_subjectcode',course FROM students WHERE studentnumber='$P_studentnumber'";
    
    if (!mysql_query($sql,$con))
    {
       die('Error: ' . mysql_error());
    }
    echo "<script type='text/javascript'>alert('Record Successfully Added'); location.href = '../instructor/cvsu-sis_students.php';</script>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to update one column from my user table . Current record in
I want to record the time using System.currentTimeMillis() when a user begins something in
I want to record web activity as would be done by a single user
Possible Duplicate: User Activity Profile and Statistics I want to record users activity in
I want to record user states and then be able to report historically based
I want to tell the user that a record was not deleted because it
For example: select * from T where T.id IN(4,78,12,45) I want the returned record
I want to record video with new iPhone SDK available on 3GS without user
I want to record that last update of user that log in into my
I have a model (UserProfile) with which I want to record a user's IP

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.