Demo by jquery-az.com
jQuery, CSS and HTML
A demo to get selected value and use in $.get jQuery
Select a product
Wheat
Rice
Sugar
Load Product Data
The PHP code
< ?php //Getting product name sent by Post method $productname = $_GET['ProductName']; //Change DB parameters and DB name as per yours $dbhostname = 'localhost'; $dbusername = 'user_name'; $dbpassword = 'password'; $conn = mysql_connect($dbhostname, $dbusername, $dbpassword); if(! $conn ) { die('Could not connect: ' . mysql_error()); } //echo 'MySQL Connected successfully'."
"; mysql_select_db("DBName") or die(mysql_error()); $sql_statemanet = "select * from tbl_products where Product_Name = '" .$productname ."'"; $rec_select = mysql_query( $sql_statemanet); if(! $rec_select ) { die('Could not retrieve data: ' . mysql_error()); } //Displaying fetched records to HTML table echo "
"; echo "
Product ID
Product
Quality
Quantity
"; // Using mysql_fetch_array() to get the next row until end of table rows while($row = mysql_fetch_array( $rec_select )) { // Print out the contents of each row into a table echo "
"; echo $row['Product_ID']; echo "
"; echo $row['Product_Name']; echo "
"; echo $row['Product_Quality']; echo "
"; echo $row['Product_Quantity']; echo "
"; } mysql_close($conn); ?>
A demo to get selected value and use in $.get jQuery
Select a product
Wheat
Rice
Sugar
Load Product Data