hi guys , i have this problem dealing with php its very simple but can anyone help me with this cause im only starting to learn this language and I don’t know where to start, its all about getting data from database using combo box , for example is when I select item in combo box it will display the price of the item into textbox and other details of the item from the database. I hope I make my self clear. Any example may do. Thank you in advance n_n

my first script

$db_host = 'localhost';
$db_user = '';
$db_pass = '';
$db_db = 'Inventory';

$db_link = mysql_connect($db_host, $db_user, $db_pass) or die('MySQL Connection Error:'.mysql_error());
	mysql_select_db($db_db) or die('MySQL Error: Cannot select table');

$sql = "SELECT item, id, unit_price, sellprice, quantity  FROM product ORDER by id";
$result = mysql_query($sql);


9 Years
Discussion Span
Last Post by aashishn86

well there are a lot of examples for that on the net..
search for creating dynamic drop down lists...


Using ajax for this would make it even nicer. Also, you're not really asking much of a valid question but are rather asking someone to write the programme for you.

Here's how you do it, in English:
You receive all item's records from the database using a MySQL statement. The data is returned in the form of an array. Using the foreach() method, you can easily populate a combo box on a form.

When the combo box form is submitted, the current item is sent using GET or POST to your script getting the rest of the details about that item and shows the page using the item's details as the initial values in your input text boxes, inside the form.

Seems like an interesting project which could even be sold eventually. Good luck with it! :)


Seems like an interesting project which could even be sold eventually. Good luck with it! :)

i thought this was pretty common kind of a thing ...........!!!


ok that would be helpful but so far im starting to learn php and i don't know ajax yet, is it possible to handle it in php? cause we are required to use php,.i've been searching for some examples on the web so that it would be easier for me to start and understand. hope some1 can help me T_T

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.