<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

Recommended Answers

All 3 Replies

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...
?>

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>

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>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.