This is for editing a record. When the user click the edit button, the id of the record will pass to editin.php page and all the value will retrieve from db and must fill in the form controls. The problem is the values sit properly in text boxes but not in combo boxes. The code i am using is
<?php
while($row = mysql_fetch_array($result))
{
array_push($dd,$row['product_code']);
$temp_pid = $row['product_code'];
echo '<option value='.$row['product_code'].' if($temp_pid == $product_code1) {echo "selected=selected"; } >'.$row['product_code'].'</option>';
}
echo '</select>';
?>
But it doesnt suit me,. Please help me doing this.
Select the option from a Combo box
Moderator: General Moderators
-
rajkumar_pb
- Forum Newbie
- Posts: 6
- Joined: Mon Oct 26, 2009 1:45 am
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Select the option from a Combo box
1. You don't have an opening <select>
2. Your IF logic is concatenated as a string so it's a string that is echoed not evaluated as PHP code
3. $product_code1 is never defined anywhere so obviously it will never == $temp_pid
2. Your IF logic is concatenated as a string so it's a string that is echoed not evaluated as PHP code
3. $product_code1 is never defined anywhere so obviously it will never == $temp_pid
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
rajkumar_pb
- Forum Newbie
- Posts: 6
- Joined: Mon Oct 26, 2009 1:45 am
Re: Select the option from a Combo box
This is just a part of the codeAbraCadaver wrote:1. You don't have an opening <select>
I'll change thatAbraCadaver wrote:2. Your IF logic is concatenated as a string so it's a string that is echoed not evaluated as PHP code
Its defined in top of the pageAbraCadaver wrote:3. $product_code1 is never defined anywhere so obviously it will never == $temp_pid