<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    Product: <select name="s_product">
                <option value="">Plz select product</option>
                <option value="1">TV</option>
                <option value="2">Fan</option>
                <option value="3">Light</option>
           </select><br/><br/><br/>
</form>
<?php
    if(isset($_POST['s_product']))
    {
        $product=$_POST['s_product'];
    $sql = "SELECT * FROM `data` join product on data.p_id=product.p_id WHERE data.p_id=$product";
?>
<table width="100%" height="25%" >
    <tr>
        <td><h3>Diller Name</h3></td>
        <td><h3>phone Number</h3></td>
        <td><h3>Date</h3></td>
        <td><h3>Invoice Number</h3></td>
        <td><h3>Product Name</h3></td>
    </tr>

<?php
    $query=mysql_query($sql);
    while($query2=mysql_fetch_array($query))
    {
        echo "<tr><td>".$query2['name']."</td>";
        echo "<td>".$query2['phone_num']."</td>";
        echo "<td>".$query2['date']."</td>";
        echo "<td>".$query2['invoice']."</td>";
        echo "<td>".$query2['p_name']."</td>";
        echo "<td>".$query2['rate']."</td></tr>";
    }
    }
?>
</table>
</body>
</html>

Add a javascript event listener, when the form changes submit the query through an AJAX request. To make it work correctly separate the query script so that it returns only the data you want to display in the page.

var product = document.getElementById('s_product');
product.addEventListener('change', triggerFunction, false);

change should be what you need for a select box. triggerFunction does the work after the user makes a selection. you will need to research this but theres plenty of documentation, you will need to research the POST / GET Ajax functions as well. Jquery makes everything easier, it is good but if your not familiar with JS I would suggest learning pure JS first.

thanks for helping me...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.