-1
我對產品的價值進行排名並將其列在下拉菜單中。我似乎無法保留從下拉菜單中選擇的排名值。任何幫助將不勝感激,在此先感謝。保留從下拉框中選擇的排名值
<?php
$sessionid = $_SESSION['uid'];
$period = ". ";
$info = $conn->prepare("SELECT `productid`,`name` FROM `products` WHERE id = :id ORDER BY `name` DESC ");
$info ->bindParam(':id', $sessionid , PDO::PARAM_INT);
$info->execute();
$rank = 0;
$last_score = false;
$rows = 0;
$ops = '';
while ($userinfo = $info->fetchobject()) {
$rows++;
if($last_score!= $userinfo->name){
$last_score = $userinfo->name;
$rank++;
}
$productid1 = "$userinfo->productid";
$name1 = "$userinfo->name";
$ops.= "<option value='" . $productid1 . "'>" . $rank . "" . $period . "" . $name1 . "</option>";
}
?>
<form action="store.php" method="POST">
<b>Select a product from our top ranking product list. </b> </br>
<select name= "products" >
<?php echo $ops ?> <?php if($_POST['products']=='$ops') echo "selected = \"selected\""; ?>>
</select>
</br>
<input type="submit" name="Submit" value="Submit"/>
</form>
這個工作。非常感謝 :) – user3595005