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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:28:52+00:00 2026-06-05T08:28:52+00:00

I’m trying to create an inventory tracker. My problem is that the inventory can

  • 0

I’m trying to create an inventory tracker. My problem is that the inventory can be anywhere from 1 item to 1 metric buttload (give or take) of items. The basic form is this:

eq.issue.php

<form name="form" method="post" action ="issue.e.php">
    <?
        $kit_query = mysql_query("SELECT * FROM eq_kit");
        while($fetch_kits = mysql_fetch_array($kit_query){
        $kitId = $fetch_kits['kit_id'];
        $kitSn = $fetch_kits['kit_sn'];
        $kitQty = $fetch_kits['kit_qty'];
    ?>
    <tr>
        <td>
            <input type="checkbox" name="kit_row[]" value="<?=$kitId?>" id="<?=$kitId?>">
        </td>
        <td>
            <input name="qty[]" type="text" id="<?=$kitQty?>" value="<?=$kitQty?>">
        </td>
        <td>
            <input name="sn[]" type="hidden" id="<?=$kitSn?>" value="<?=$kitSn?>"
        </td>
    </tr>
    <? } ?>
    <input type="submit" name="Submit" id="Submit" value="Submit">
</form>

on the receiving side:

issue.e.php

<? // all the database crap

if(is_array($kit_row)){
    foreach($_POST['kitrow'] as $key=>$val){
        $sn=$_POST['sn'];
        $serial = $sn[$val];
        $qty = $_POST['qty'];
        $quant = $qty[$val];

    mysql_query("INSERT INTO eq_issue SET issue_sn = '$serial', issue_qty = '$quant'")or die(mysql_error());

This works well for an individual item as well as consecutive items.

With an example of this as my eq.issue.php form:

|Check | Qty | SN  |
==================== 
| X    | 100 |12345| 
|      | 1   |23456| 
|      | 1   |98765| 
| X    | 999 |19283|
==================== 
|Submit|

My problem is that if I choose the 1st and 4th option for example, the arrays now appear like this:

kit_row => Array
  0 => 4
  1 => 3

qty => Array
  0 => 100
  1 => 1
  2 => 1
  3 => 999

sn => Array
  0 => 12345
  1 => 23456
  2 => 98765
  3 => 19283

Thus, as my script plays out, I get values for the 4th option as kit_row => 3 qty => 1 sn=> 23456, where I want it to display kit_row=> 3 qty => 999 sn => 19283.

Any suggestions on how I can make this work? For a better visual reference, I am trying to acheive the same concept as PHPMyAdmin’s multi-value insert page using checkboxes to say which group (or rows) of records I want to insert.

  • 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-05T08:28:55+00:00Added an answer on June 5, 2026 at 8:28 am

    You could foreach over $_POST['qty'] or $_POST['sn'] instead of $_POST['kit_row'].

    Or use the kit_id as index for your form fields, which would make it possible on the server side to know what’s what:

    <input type="checkbox" name="kit_row[<?=$kitId?>]" value="1">
    <input name="qty[<?=$kitId?>]" type="text" id="<?=$kitQty?>" value="<?=$kitQty?>">
    <input name="sn[<?=$kitId?>]" type="hidden" id="<?=$kitSn?>" value="<?=$kitSn?>">
    

    This way you can access the posted data on the server with the ID from the database, rather than using 0, 1, 2… like this:

    if (is_array($_POST['kit_row']))
    {
        foreach ($_POST['kit_row'] as $kitId => $val)
        {
            $sn=$_POST['sn'];
            $serial = $sn[$kitId];
            $qty = $_POST['qty'];
            $quant = $qty[$kitId];
    

    Also possible is adding a hidden field with the same name and value 0 in front of each checkbox. You’d have to replace kit_row[] with a real index though:

    <input type="hidden" name="kit_row[<?php echo $i; ?>]" value="0">
    <input type="checkbox" name="kit_row[<?php echo $i++; ?>]" value="1">
    

    This way the value gets submitted in both cases, ticked and unticked.

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

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I am currently running into a problem where an element is coming back from
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.