简体   繁体   English

从数据库显示中选择选项到另一个页面

[英]select option from database display to another page

Please help me how to display this select option dropdown to another page. 请帮助我如何将此选择选项下拉菜单显示到另一页。 i got the correct content of the database and when i submit the button the one that it display if always the first row or (default). 我得到了正确的数据库内容,并且当我提交按钮时,如果总是第一行或(默认),它将显示该按钮。 PLEASE. 请。

$select_size = mysql_query("SELECT * FROM size_tbl WHERE prod_id ='$prod_aydi' ");
?>  
Size: &nbsp; <select class="details_order1" name="size" >
<?php
while($data=mysql_fetch_assoc($select_size))
{
    $prod_diay = $data['prod_id'];
    $sze = $data['size_name'] ;
    ?>
    <option value="<?php echo $prod_diay ?>"><?php echo $sze ?></option>
    <?php
}
?>
</select>

FUNCTION.php FUNCTION.php

function get_size($pid) {
    $result=mysql_query("select id from product_tbl where id='$pid' ") ;
    $row=mysql_fetch_array($result);    
    $aydi = $row['id'];

    $sel = mysql_query("SELECT size_name FROM size_tbl WHERE prod_id='$aydi' ");
    $row2 = mysql_fetch_array($sel);            
    return $row2['size_name'];
}

您需要在页面加载时将“ selected”属性添加到要选择的<option>中。

<option selected>...</option>
<option value="<?php echo $prod_diay ?>" <?php if($sze == '$row2['size_name'] ') 
echo" selected ";  ?> >
<?php echo $sze ?></option>

would give you the selected option , ie like if you are doing an update or something. 会为您提供选定的选项,例如,如果您正在执行更新或其他操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM