0

First I would like to update the records. I created dropdown box which has values from mySQL FROM SELECT statemet it's working fine with one previously selected database entry. but what I would like to have another values for the modification wich i have in another table.

DROP DOWN FOR THE UPDATE from order table value.

    echo '<div class = "MediaType" >'; //Start class Media Type
    echo '<strong><label for="rate">Media Type</label></strong>';
    echo '<br/><br/>' ;

        $sql = "SELECT `media_type` FROM `order` where `po_number` = '".$ponumber."'";
        $result = mysql_query($sql);

        while ($row = mysql_fetch_array($result)) 
            {
                echo "<select class='dropdownsize' name='media_type[]' tabindex='$k'>";

                echo "<option value='" . $row['media_type'] . "'>" . $row['media_type'] . "</option>";
                echo '</select>';
                echo '<br/>';
            }

echo '</div>'; //End Class Media Type

It's give me value "ONLINE" in dropdown which I selected and Inserted during the Insert process.

DROP DOWN FOR INSERT Page from media_type table

echo '<div class = "MediaType" >'; //Start class Media Type
    echo '<strong><label for="rate">Media Type</label></strong>';
    echo '<br/><br/>' ;

        //for loop for dropdown from user index//
        for($k=1;$k<=$textboxindex;$k++)
        {
        $sql = "SELECT media_type FROM media_type";
        $result = mysql_query($sql);
            echo "<select class='dropdownsize' name='media_type[]' tabindex='$k'>";
            while ($row = mysql_fetch_array($result)) 
            {
                echo "<option value='" . $row['media_type'] . "'>" . $row['media_type'] . "</option>";
            }
            echo '</select>';
            echo '<br/>';
        }
echo '</div>'; //End Class Media Type

table name = "media_type" values = "TV","ONLINE","Roller",Banner","Roll Over"

I want to have this "media_type" values in my update drop box as same as the insert dropbox so enduser can modify entry with media_type values as Insert. but when it's display 1st time then default values of dropbox should be same as previous entered data.

sorry my question is confusing. What is the best way to doing.? Any help will be appreciate. thank You

000
  • 3,976
  • 4
  • 25
  • 39
user1778175
  • 47
  • 1
  • 7

1 Answers1

1

First of all please go through Why shouldn't I use mysql_* function in PHP?

As per your existing code, you can modify your DROP DOWN FOR THE UPDATE from order table value. with the below code..Here we are running a second while loop to get the desired results..

Also please note that it may not be the right way when there are thousands of options to be appended in terms of performance..

echo '<div class = "MediaType" >'; //Start class Media Type
    echo '<strong><label for="rate">Media Type</label></strong>';
    echo '<br/><br/>' ;

        $sql = "SELECT `media_type` FROM `order` where `po_number` = '".$ponumber."'";
        $result = mysql_query($sql);

        while ($row = mysql_fetch_array($result)) 
            {
                echo "<select class='dropdownsize' name='media_type[]' tabindex='$k'>";

                echo "<option value='" . $row['media_type'] . "'>" . $row['media_type'] . "</option>";


        $sql2 = "SELECT media_type FROM media_type";
        $result2 = mysql_query($sql2);
        while ($row2 = mysql_fetch_array($result2)) 
            {
            echo "<option value='" . $row2['media_type'] . "'>" . $row2['media_type'] . "</option>";
            }



                echo '</select>';
                echo '<br/>';
            }

echo '</div>'; //End Class Media Type
Community
  • 1
  • 1
000
  • 3,976
  • 4
  • 25
  • 39