tobitimac Posted April 27, 2011 Share Posted April 27, 2011 Hi i have the data below in my database, i will want the users to use a drop down that wont show a duplicate data in item field and if the user select an item it should the total number of the item from qty field. HERE IS MY DATA Item Qty 1055-2X 1471 1055-2X 2 1055-2X 4 1055-2X 0 1055-3X 413 1055-3X 0 1055-3X 0 1055-3X 0 1055-4X 15 1055-4X 0 1055-4X 0 1055-4X 0 1055-5X 28 WANTS THE DROP DOWN MENU TO SHOW item 1055-2X 1055-3X 1055-4X 1055-5X ONCE ANY ITEM IS SELECTED I WANT TO DISPLAY THE TOTAL SUM OF THE ITEM TO SHOW for example if i select 1055-2X i want to show item Qty 1055-2X 1477 Please any help? here is my current script which shows everything. <? if(isset($select)&&$select!=""){ // Get records from database (table "name_list"). $result=mysql_query("select distinct from inventory where id='$select'"); while ($row=mysql_fetch_assoc($result)) { echo"<b>"; echo "<tr><td style=\"font-size: 15px;\"><b>"; echo $row['itemNumber']; echo "</td><td style=\"font-size: 15px;\"><b>"; echo $row['itemDesc']; //echo "</td><td style=\"text-align: right;\"><b>"; echo "</td><td style=\"font-size: 15px; text-align: center;\"><b>"; echo $row['quantityHand']; echo"</b>"; // End While loop } // End if statement. } $sql = "select * from inventory ORDER BY itemNumber ASC"; $result = mysql_query ($sql); while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['itemNumber']; echo "</td><td>"; echo $row['itemDesc']; //echo "</td><td style=\"text-align: right;\">"; echo "</td><td style=\"text-align: center;\">"; echo $row['quantityHand']; echo "</td></tr>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/234890-how-to-add-value-in-a-field/ Share on other sites More sharing options...
Maq Posted April 27, 2011 Share Posted April 27, 2011 In the future, please use tags around your code. Quote Link to comment https://forums.phpfreaks.com/topic/234890-how-to-add-value-in-a-field/#findComment-1207092 Share on other sites More sharing options...
fenway Posted April 28, 2011 Share Posted April 28, 2011 Assuming that format is uniform, you can just split on space. Quote Link to comment https://forums.phpfreaks.com/topic/234890-how-to-add-value-in-a-field/#findComment-1207300 Share on other sites More sharing options...
tobitimac Posted April 28, 2011 Author Share Posted April 28, 2011 Assuming that format is uniform, you can just split on space. How can i do am new to PHP. Quote Link to comment https://forums.phpfreaks.com/topic/234890-how-to-add-value-in-a-field/#findComment-1207301 Share on other sites More sharing options...
fenway Posted April 28, 2011 Share Posted April 28, 2011 Not PHP -- use SUBSTRING_INDEX(). Quote Link to comment https://forums.phpfreaks.com/topic/234890-how-to-add-value-in-a-field/#findComment-1207329 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.