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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:21:07+00:00 2026-05-24T01:21:07+00:00

Hello I have a form which have subj_ids. So here’s the scenario. I have

  • 0

Hello I have a form which have subj_ids. So here’s the scenario. I have subj_ids 1, 2, 3, 4, 6 but what happens everytime I am submitting the form it inserts a record with 0 value plus it doesn’t insert a record with a subj_id of 6.

FORM:

    <tr>
        <td width="225"><?= $row_subjects[1];?>
        <?php if($row_active_term[0] == '1st' && $row_active_term[1] == '1' ) {?>
        <td align="center"  width="225">
            <?php if($row_subjects['indicator'] == 'editable'){?>
                <input type="hidden" name="subj_id_<?= $row_subjects[0]?>" id="subj_id_<?= $row_subjects[0]?>" value="<?= $row_subjects[0]?>" />
                <input type="text" name="grade_<?= $row_subjects[0]?>" id="grade_<?= $row_subjects[0]?>" size="5" value="<?= number_format($row_subjects[4], 1)?>" />
            <?php } else {?>
                <a href="#" title="This is your downfall">?</a>
            <?php } ?>
        </td>
        <?php } ?>
    </tr>

Submission:
I guess this is where the bad code lies. . .

    <?php
include('conn.php');
$uid = $_SESSION['uid'];
$rs_count_subjs = mysql_query("select count(*) as x from teachers_subjects where tid = $uid");
$row_count_subjs = mysql_fetch_array($rs_count_subjs);
$x = $row_count_subjs['x'];
$term = $_POST['term'];
//echo "select count(*) as x from teachers_subjects where tid = $uid";

$rs_subjs = mysql_query("select * from teachers_subjects where tid = $uid");
$row_subjs = mysql_fetch_array($rs_count_subjs);

for($i=0; $i<=$x; $i++) {
$t = $row_subjs[0];
$sid = $_POST['sid'];
$s = $_POST['subj_id_'.$i];
$y = $_POST['grade_'.$i];
$rs = mysql_query("select * from student_friggin_grades where sid = '$sid' AND subj_id = '$s' AND term = '$term' AND tid = $uid");
$row = mysql_fetch_array($rs);
$num = mysql_num_rows($rs);
    if($num > 0) {
        $update_grade = "update set grade = '$y' where sid = '$sid' AND subj_id = '$s' AND term = '$term' AND tid = $uid";
        $updated_grade = mysql_query($update_grade);
        $is_updated = mysql_affected_rows();
        echo "update set grade = '$y' where sid = '$sid' AND subj_id = '$s' AND term = '$term' AND tid = $uid";
    } else {
        $update_grade = "insert into student_friggin_grades(`sid`, `subj_id`, `term`, `grade`, `tid`, `date_added`, `date_updated`) 
                values('$sid', '$s', '$term', '$y', $uid, NOW(), NOW())";
        $updated_grade = mysql_query($update_grade);
        $is_updated = mysql_affected_rows();
    }
}

if($is_updated > 0) {
    header("Location: show_grades.php?sid=$sid");
}
?>

Please help me,

Xxxxxxxxxxxxxxxx

  • 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-24T01:21:08+00:00Added an answer on May 24, 2026 at 1:21 am

    assuming $x is equal to 6,

    for($i=0; $i<=$x; $i++) {
    

    will give you 0 through 6
    if you want to traverse 1 through 6

    for($i=1; $i <= $x; $i++) {
    

    however this does not answer why you did not see 6, unless $x is in fact equal to 5.

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

Sidebar

Related Questions

I have a Textarea which is in a form that has this value Hello<div
Hello i have this form filling javascript: function onLine(code,nn) { document.writeform.bericht.value+=code; document.writeform.bericht.focus(); document.writeform.nickname.value+=nn; write1();
Hello I have a form which has two buttons. In the form validation (onsubmit
Hello All, I have a form which have 5 step and in final step
I have a windows form application which consists of a bunch of controls, but
Hello i have a list view control, While the form is being loaded i
I have the following form code: # forms.py class SomeForm(forms.Form): hello = forms.CharField(max_length=40) world
Hello I have next function, what always return null as result, but service calling
i have a django form which generates the qrcode, the form does show up
I have a web service to which I send a xml request (application/x-www-form-urlencoded encoded)

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.