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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:39:07+00:00 2026-06-18T07:39:07+00:00

Current summary of the problem: I am pulling in information from table ‘main’ that

  • 0

Current summary of the problem: I am pulling in information from table ‘main’ that lists out Goal Number and Goal Name for a specific ID (there can be up to 10 rows). These are displayed in a table on the web page. I added checkboxes in the first column that reflect the amount of rows in the table. The code for this is below, this part is working correctly. The out put is 3 columns, Checkbox, Goal Number, Goal Name, and up to 10 rows depending on amount of information in the table for that specific ID.

goals.php

<tr>
        <td valign=top colspan=3>
            Current Goals<br>
                <?php
                //this data is being pulled from 'main'
                    $result = mysql_query("SELECT * FROM main WHERE idnumber = $idnumber ORDER BY goalnumber");
                    if ($result) {
                    $total_rows = mysql_numrows($result);
                    } else { $total_rows = 0; }
                    print "<table border=1 width=400>\n";
                    print "<tr> \n";
                    print "<th> Checkbox </th> \n";
                    print "<th> Goal Number </th> \n";
                    print "<th> Goal Name </th> \n";
                    print "</tr> \n";
                    //}
                    $i = 0;
                    while ( $i < $total_rows )
                    {
                    $goalno = intval(mysql_result($result, $i, "goalnumber"));
                    $goalname = mysql_result($result, $i, "goalname");
                    $goal_id = intval(mysql_result($result, $i, "goal_id"));
                    print "<tr> \n";
                    print "<td> <center><input type=\"checkbox\" name=\"goal_id_$i\" value=\"$goalnumber - $goalname\"></td> \n";
                    print "<td> $goalnumber </td> \n";
                    print "<td> $goalname </td> \n";
                    print "</tr> \n";
                    $i = $i + 1;
                    }
                ?>
                </table>
        </td>

Once a user checks anywhere from 1-10 of these checkboxes and submits the form, I need to pass the values of said selections to the db (each selection should be written to a new field in the db table ‘updated_goals’. On submit the below file gets called. Note that I am writing the checkbox value to a different table in the same db ‘updated_goals’. I am not sure where I am going wrong with the code, but the goal is to write the values of the checkbox, “$goalnumber – $goalname” into the goal_id field.

goals_submit.php

// process data in table: updated_goals
$query = "SELECT idnumber from updated_goals where idnumber = {$_POST['idnumber']}";
$result = mysql_query($query);
$total_rows = mysql_numrows($result);

            //writing data to 'updated_goals'

        if (isset($_POST ['goal_id_$i'])) { $goal_id = ReplaceQuotes($_POST['goal_id_$i']); } else { $goal_id = ""; }

    $query = "INSERT INTO updated_goals ( ";
    $query .= "goal_id ";
    $query .= ") VALUES ( ";
    $query .= "'$goal_id' ";
    $query .= ")";
  • 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-18T07:39:08+00:00Added an answer on June 18, 2026 at 7:39 am

    Possible solutions:

    Change this line:

    if (isset($_POST ['goal_id'][$i])) { $goal_id = ReplaceQuotes($_POST['goal_id'][$i]); } else { $goal_id = ""; }
    

    to

    if (isset($_POST ['goal_id_'.$i])) { $goal_id = ReplaceQuotes($_POST['goal_id_'.$i]); } else { $goal_id = ""; }
    

    or
    change this line

    print "<td> <center><input type=\"checkbox\" name=\"goal_id_$i\" value=\"$goalnumber - $goalname\"></td> \n";
    

    to

    print "<td> <center><input type=\"checkbox\" name=\"goal_id[$i]\" value=\"$goalnumber - $goalname\"></td> \n";
    

    if array used for input name for example:
    inputname[]
    it can be get via POST or GET by $_POST[‘inputname’][index] or $_GET[‘inputname’][index]

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

Sidebar

Related Questions

A] Problem summary: I have JSON data being returned from python to javascript. I
Summary: I want the prettiness of Silverlight/WPF in part of my current Winforms application.
Current situation: Ubuntu 8.04 server edition (live server) Postgresql 8.3.7 (from standard repositories) Postgis
I having a problem with my current situation, I searched through any solution on
Summary We have an ASP.NET application that allows users to query a SQL Server
I have a UI that looks similar to the mail app. A table view
Summary I currently have a NAnt build script that performs a vssget on either
Summary I am creating a simple application that allows the user to select a
I am currently developing a solution that uses YUI grids. My problem is that
Current requirement is on button click I am getting a json data through ajax

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.