garrickplaisted Posted September 14, 2012 Share Posted September 14, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/268349-need-help-with-displaying-data-from-an-array/ Share on other sites More sharing options...
trq Posted September 14, 2012 Share Posted September 14, 2012 mysql_fetch_array expects a result resource (see mysql_query) not a string. Quote Link to comment https://forums.phpfreaks.com/topic/268349-need-help-with-displaying-data-from-an-array/#findComment-1377786 Share on other sites More sharing options...
Barand Posted September 14, 2012 Share Posted September 14, 2012 Also IN('$sell_inv') should be a list of integers (1,2,3) not a string. Remove the single quotes. Quote Link to comment https://forums.phpfreaks.com/topic/268349-need-help-with-displaying-data-from-an-array/#findComment-1377824 Share on other sites More sharing options...
garrickplaisted Posted September 14, 2012 Author Share Posted September 14, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/268349-need-help-with-displaying-data-from-an-array/#findComment-1377884 Share on other sites More sharing options...
garrickplaisted Posted September 14, 2012 Author Share Posted September 14, 2012 mysql_fetch_array expects a result resource (see mysql_query) not a string. Thank you Thorpe. I will look into that, I have no idea what a result resource is or should be. Quote Link to comment https://forums.phpfreaks.com/topic/268349-need-help-with-displaying-data-from-an-array/#findComment-1377887 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.