0

My previous problem got solved but know i want to use html select value as input to another mysql query. My code so far -

<?php
    $con=mysqli_connect("server","user","pwd","db");
    if (mysqli_connect_errno())
    {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
    $result = mysqli_query($con,"select eid from tbl1 order by eid;");
    ?>
    <select id="eid" size="1">                                      
    <option selected="true" disabled="disabled">Choose eid</option>        
<?
    while($row = mysqli_fetch_array($result))
    {
?>
    <option value="<? echo $row_list['eid']; ?>"<? if($row['eid']==$select){ echo "selected"; } ?>>
    <?echo $row['eid'];?>
    </option>

<?

    }
    ?>
    </select>
    <select name="tagging">
    <option selected="true" disabled="disabled">Choose tagging</option> 
    <option value="option1">option1</option>
    <option value="option2">option2</option>
    <option value="option3">option3</option>
    </select>
<?
    $result = mysqli_query($con,"select  distinct val from tbl2 where val!='' order by val;");
?>
    <select id='val'>
    <option selected="true" disabled="disabled">Choose val</option> 
<?

    while($row = mysqli_fetch_array($result))
    {
?>
    <option value="<? echo $row_list['val']; ?>"<? if($row['val']==$select){ echo "selected"; } ?>>
    <?echo $row['val'];?>
    </option>
<?

    }
    ?>
    </select>
<?  
    mysqli_close($con);
?> 

Now the output window have three html select, i want to pass this three value in mysql select query to show some result. But don't know how to do it. All kind of advice are welcome.

0

2 Answers 2

1

There are few things you need to include in your web script pages.

  1. All input fields should be enclosed in a <form object.
  2. All input fields that should go to server must have name="value" defined.
  3. Form must have action="url" defined, to submit to a different web page.
  4. Scripting language in the server, should read these name=value pairs and based on your condition, should pass to database engine to store in a table.
Sign up to request clarification or add additional context in comments.

2 Comments

2. On <select id="eid">: It won't be recognized by the server script unless you include a name attribute's value to it.
My final code got too much changed, used Ajax and much more stuff but at the end used Form for initial query, so +1`.
1

Why dont you wrap those 3 <select></select> into a <form> tag and add action and method attributes such as <form action="file_to_handle_select_data.php" method="POST"> and than in file_to_handle_select_data.php run the queries from $_POST array.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.