0
    <tr class="tablerow">
      <td>Page Id</td>
      <td><select name='PageId' class="select">
          <option  value='0' >select any page</option>

          <?php
$sql10 = "SELECT Id,Title FROM abc";
$rs = mysql_query($sql10) or die(mysql_error());
while($row = mysql_fetch_array($rs)){

echo "<option value='".$row["Id"]."'>".$row["Title"]."</option>";
}
mysql_free_result($rs);

?>

this done show all title from table
but when i update form i want that the tile i insert in to db table selected

4
Contributors
3
Replies
25
Views
3 Years
Discussion Span
Last Post by shophiarajan47
0

Your Question is in very Bad Language. This is what I understood from it so I'll answer for that:
You want to insert the selected page from the drop down in the Database.

First of all Close the select tag.
It is also preferable if you remove the table tags as it may cause some problems.
Then put this whole thing inside <form></form> tags.
Something like this:

<form action="insertintodb.php" method="post">
    <!-- Whole Select tag here -->
</form>

Then in insertintodb.php access the passed page like this:

<?php
    $pagenum = $_POST['PageId'];
    //Code to insert into table here...
?>
0

you have to use if condition for getting the inserted data from the database.

Example

    <option value="<?php echo $row["Id"];?>"<?php if($row["Id"]==Edit query data Value){?>selected="selected"<?php } ?><?php echo $row["Title"]; ?></option>

Edited by rpv_sen: update some text

0

Try writing the things in HTML rather in PHP like belwo it's may work -

<select name='PageId' class="select">
    <option  value='0' >select any page</option>
    <?php
    $sql10 = "SELECT Id,Title FROM abc";
    $rs = mysql_query($sql10) or die(mysql_error());
    while($row = mysql_fetch_array($rs)){
    ?>
    <option value="<? echo $row['Id']; ?>" > <? echo $row['Title']; ?></option>
    }
    <? mysql_free_result($rs);
    ?>
    </select>
This question has already been answered. 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.