Get data from two files

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kirke

    #1

    Get data from two files

    Hi,

    I want to write such code :

    // receive and save the variable as Engine ID
    $EngineID = (int)$_POST['EngineType'];

    dbconnect();

    // In the file named dbo_J1708Vehicl e, I want to get the list of
    numbers in the column of iVehicleID

    $sql = "SELECT iVehicleID FROM dbo_J1708Vehicl e
    WHERE iEngineTypeId = $EngineID";
    $result = mysql_query($sq l) or die();
    $row = mysql_fetch_arr ay($result)

    // In drop-down box, I want to show the numbers in the file named
    dbo_Vehicle, in the column of sDescriotion where iID= iVehicleID value
    in prev result.

    $sql2 = "SELECT * FROM dbo_Vehicle WHERE (iID) in ($row)";
    $result2 = mysql_query($sq l2) or die();

    while( $row2 = mysql_fetch_arr ay($result2) )
    {
    echo '<option
    value="'.$row2['sDescription'].'">'.$row2['sDescription'].'</option>';
    }




    However, as you guess, it doesn't work. My another guess is.


    $EngineID = (int)$_POST['EngineType'];
    dbconnect();
    $sql = "SELECT iVehicleID FROM dbo_J1708Vehicl e
    WHERE iEngineTypeId = $EngineID";
    $result = mysql_query($sq l) or die();
    $row = mysql_fetch_arr ay($result)

    while( $row = mysql_fetch_arr ay($result) )
    {
    $sql2 = "SELECT * FROM dbo_Vehicle
    WHERE iID = .$row";
    $result2 = mysql_query($sq l2) or die();
    $row2 = mysql_fetch_arr ay($result2)
    echo '<option
    value="'.$row2['sDescription'].'">'.$row2['sDescription'].'</option>';
    }

    However, also i doesn't work. Do you guys have any idea?
    Thx alot.

  • kirke

    #2
    Re: Get data from two files

    i found it. what i want to do is


    require('conf.p hp');
    $EngineID = (int)$_POST['EngineType'];

    dbconnect();
    $sql = "SELECT dbo_Vehicle.* FROM dbo_J1708Vehicl e, dbo_Vehicle
    WHERE dbo_J1708Vehicl e.iEngineTypeId = $EngineID AND
    dbo_J1708Vehicl e.iVehicleID=db o_Vehicle.iID";
    $result = mysql_query($sq l) or die();

    while ($row = mysql_fetch_arr ay($result))
    {
    echo '<option value="'.$row['sDescription'].'" >
    '.$row['sDescription'].' </option>';
    }



    kirke wrote:
    Hi,
    >
    I want to write such code :
    >
    // receive and save the variable as Engine ID
    $EngineID = (int)$_POST['EngineType'];
    >
    dbconnect();
    >
    // In the file named dbo_J1708Vehicl e, I want to get the list of
    numbers in the column of iVehicleID
    >
    $sql = "SELECT iVehicleID FROM dbo_J1708Vehicl e
    WHERE iEngineTypeId = $EngineID";
    $result = mysql_query($sq l) or die();
    $row = mysql_fetch_arr ay($result)
    >
    // In drop-down box, I want to show the numbers in the file named
    dbo_Vehicle, in the column of sDescriotion where iID= iVehicleID value
    in prev result.
    >
    $sql2 = "SELECT * FROM dbo_Vehicle WHERE (iID) in ($row)";
    $result2 = mysql_query($sq l2) or die();
    >
    while( $row2 = mysql_fetch_arr ay($result2) )
    {
    echo '<option
    value="'.$row2['sDescription'].'">'.$row2['sDescription'].'</option>';
    }
    >
    >
    >
    >
    However, as you guess, it doesn't work. My another guess is.
    >
    >
    $EngineID = (int)$_POST['EngineType'];
    dbconnect();
    $sql = "SELECT iVehicleID FROM dbo_J1708Vehicl e
    WHERE iEngineTypeId = $EngineID";
    $result = mysql_query($sq l) or die();
    $row = mysql_fetch_arr ay($result)
    >
    while( $row = mysql_fetch_arr ay($result) )
    {
    $sql2 = "SELECT * FROM dbo_Vehicle
    WHERE iID = .$row";
    $result2 = mysql_query($sq l2) or die();
    $row2 = mysql_fetch_arr ay($result2)
    echo '<option
    value="'.$row2['sDescription'].'">'.$row2['sDescription'].'</option>';
    }
    >
    However, also i doesn't work. Do you guys have any idea?
    Thx alot.

    Comment

    Working...