drop down box problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arunj82
    New Member
    • Mar 2007
    • 15

    #1

    drop down box problem

    Hi,
    In my php page i have combo box which has problem numbers.

    Eg:
    Select the Problem ID to view the Problems :
    Code:
    <select name="proid" onChange="dispValues()">
    <option value="">Please Select</option>
    <option value="PROB001">PROB001</option>
    <option value="PROB002">PROB002</option>
    <option value="PROB003">PROB003</option>
    <option value="PROB004">PROB004</option>
    <option value="PROB005">PROB005</option>
    </select>
    when i select the problem number in combo box, it should display customername,ci ty,email,proble m details from the db in html table format.
    how do i retrieve combo box value i.e problem numbers in php scripts. i.e how to retrieve the combo box value in sql query. u pls help me.Thats y i put ? mark there.what is the query to retrieve te values from the db when i click the combo box
    [php]
    <?php
    $sql="select * from customer where probid="?"
    $result=mysql_q uery($sql) or die(mysql_error ());
    while($row = mysql_fetch_arr ay($result))
    {
    echo "<tr>";
    echo "<td>" . $row['custname'] ."</td>";
    echo "<td>" . $row['city'] . "</td>";
    echo "<td>" . $row['phno']. "</td>";
    echo "<td>" . $row['email']. "</td>";
    echo "<td>" . $row['problem']. "</td>";
    echo "<td>" . $row['probid']. "</td>";
    echo "</tr>";
    }
    ?>[/php]

    Please read the Posting Guidelines before you post in this forum!
    Especially the part about enclosing shown code within code or php tags!!!

    moderator
    Last edited by ronverdonk; Mar 5 '07, 03:57 PM. Reason: code within tags
  • ak1dnar
    Recognized Expert Top Contributor
    • Jan 2007
    • 1584

    #2
    Try This coding.I dont know what you have done in dispValues() function.
    Make sure to POST the Form using this function.
    Thats what i am putting this action="" blank.
    since you are not using a Button, using JavaScript you have to Submit the form.
    :)

    [HTML]<form name="myform" action="" method="POST">
    <select name="proid" onChange="dispV alues()">
    <option value="">Please Select</option>
    <option value="PROB001" >PROB001</option>
    <option value="PROB002" >PROB002</option>
    <option value="PROB003" >PROB003</option>
    <option value="PROB004" >PROB004</option>
    <option value="PROB005" >PROB005</option>
    </select>
    </form>[/HTML]

    your_php_file.p hp

    [PHP]<?php
    $probid = $_POST['proid'];

    $sql="select * from customer where probid='$probid '"
    $result=mysql_q uery($sql) or die(mysql_error ());
    while($row = mysql_fetch_arr ay($result))
    {
    echo "<tr>";
    echo "<td>" . $row['custname'] ."</td>";
    echo "<td>" . $row['city'] . "</td>";
    echo "<td>" . $row['phno']. "</td>";
    echo "<td>" . $row['email']. "</td>";
    echo "<td>" . $row['problem']. "</td>";
    echo "<td>" . $row['probid']. "</td>";
    echo "</tr>";
    }
    ?>[/PHP]

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      How could we help without all the code available? So, show the DispValues() function code.

      And enclose it within code tags!

      Ronald :cool:

      Comment

      Working...