0
      <?php
        connection check;
        select database;
        $sql="select * from category"
        mysql_query($sql);
        $prod_name=$_POST["prod_name"];

/pls tell me what to pass in cat_id down i have to take the select tag's value property then what should i pass pls help me........./
$cat_id="What to write here...."
sql1="insert into product(prod_name,cat_id) values('".$prod_name."','".$cat_id."');
$r=mysql_query($sql1);
?>

        <html>
            <form>
                <select id=prod name=prod>
                    <?php
                        while ($row=mysql_fetch_array($r))
                        {
                            echo "<option value=".$row["cat_id"].">$row["cat_name"] </option>";   
                        }
                        //can you tell me how to add the above value of cat_id and insert to table....
                    ?>
                </select>
            </form>
        </html>

Edited by vinay7868

2
Contributors
4
Replies
8
Views
5 Years
Discussion Span
Last Post by vinay7868
0

When will you want to insert cat_id ? When the form has submitted ? You must have action to process server-side script. So, put action in your form via "action=somewhere" attribute. Somewhere could be server-side language php / jsp / asp file. Then, you can get the data in this page submitted by form and insert into database table with specific language (PHP-MySQL, ASP-MsSQL, etc.).

0
        <html>
            <form action="allprod.php" method="post">
                <select id=prod name=prod>
                    <?php
                        while ($row=mysql_fetch_array($r))
                        {
                            echo "<option value=".$row["cat_id"].">$row["cat_name"] </option>";   
                        }
                        //can you tell me how to add the above value of cat_id and insert to table....
                    ?>
                </select>
            </form>
        </html>

now pls tell me that should i pass $row["cat_id"] as a cat_id or some thing else which is selected.....

Edited by vinay7868

0

You can now get 'cat_id' in allprod.php by using $_POST['prod'], and then, go with your SQL query to insert that value into table.

0

so i should insert after the while loop and fire the sql query.....

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.