Jump to content

Recommended Posts

First I would like to thank anyone who takes the time to help me with this!! 

 

Ok so I have an inventory.php page that has two drops downs. The first one is Products and the Second one is Events. When you chose a selection is will display any product still in inventory along with other information specific to the transaction. So for example if I choose socks in the Products drop down, it will show me all socks still in inventory. If I choose Event 1 from the Events drop down, it will show me all products purchased at that event. When it displays the results it will also display a check mark with each set of results and the transaction id as the value of the checkbox. It also displays a Sell button, Check All and Uncheck All buttons. When the Sell button is click it the form action sends you to sell_inventory.php page. This is the page I really need help with. So on this page I need to somehow display information based on the results of the previous page. Here is the code I have for that thus far:

 

Here is the code that echos the results for the drop down selection. This is where the checkbox is.

            echo "<div class='span2 well-inner'>";
            echo "<input type='checkbox' class='checkbox float-right' name='sell_inv[]' value='" . $inventoryRow['transactionID'] . "'>";
            echo "<strong>Product: </strong>" . $inventoryRow['product'] . "<br/>";
            echo "<strong>Price: </strong>" . $inventoryRow['productPrice'] . "<br/>";
            echo "<strong>Weight: </strong>" . $inventoryRow['metalWeight'] . "<br/>";
            echo "<strong>Cost: </strong>$" . $inventoryRow['transactionTotal'];
            echo "</div>";

 

Here is the query that am using.

           $transactionsTable = "transactions";
           $sell_inv = implode(',',$_POST['sell_inv']);
           $inventorySQL="SELECT * FROM $transactionsTable WHERE transactionID IN('$sell_inv')";
           $info = array();

 

Here is where I am stuck. I am able to print the array out and it displays the Key with the id, but I am not sure how to display specific data tied to the id. Like the Product name. I have tried so many different things and nothing seems to work. I am going crazy!! Here is what I have currently:

<?php
        
        <!--- This prints the array just fine -->
        echo "<pre>";
        print_r ($_POST['sell_inv']);
        echo "</pre>";
        
       <!-- This throws and error -->
       while($row=mysql_fetch_array($inventorySQL, MYSQL_ASSOC))
           $info[] = $row;
        foreach ($info as $data){
            echo $data['product'];
        }
        ?>

 

Here is the error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /sell_inventory.php on line 78

 

Line 78 is:

while($row=mysql_fetch_array($inventorySQL, MYSQL_ASSOC))

 

I need to be able to display any and all information from the database table tied to the transaction id for each transaction selected on the precious page. I hope all this makes sense and again any help would be greatly appreciated.  :confused:

Also

 

IN('$sell_inv')

 

should be a list of integers (1,2,3) not a string. Remove the single quotes.

 

Thanks for that, I appreciate it. Still trying to figure out what Thorpe sent me. Trying to research it a little more. I am fairly new to PHP and just starting to work with arrays.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.