Size: <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>
的functions.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'];
} 这是我在select选项中选择的内容,但我只获得了数据库中的默认或第一行
<?php echo $psize ?>
答案 0 :(得分:0)
Wherever we want use php with html then use syntax like this.
this is html with php code.
<select>
<option>Select any name</option>
<?php
$fetch_info=mysql_query("select `id`,`name` from user_details") or die(mysql_error());
while($row=mysql_fetch_array($fetch_info)){
echo '<option value='.$row['id'].'>'.$row['name'].'</option>';
}
?>
</select>
Thank you