尝试使用INNER JOIN函数将id分解为选项值 您会协助寻找缺失的东西吗? 下面是我的代码:
<select name="productSize" class="span8 tip" required>
<?php $query=mysqli_query($con,"select size.id,size.sizeName from size
INNER JOIN products ON size.id=products.productSize where
products.id='$pid'");
while($row = mysqli_fetch_assoc($query)) {
$size = $row['productSize'];
$boom = explode(",", $size);
foreach ($boom as $row){
echo '<option value='.$row['id'].'>'.$row['sizeName'].'</option>';
} ?>
</select>
更新: 感谢大家指出我的错误,下面是更新的代码,其中显示了productSize逗号分隔的ID作为选项值。
<?php $query=mysqli_query($con,"select size.id, size.sizeName,
products.productSize from size INNER JOIN products ON
size.id=products.productSize WHERE products.id='$pid'");
while($row = mysqli_fetch_assoc($query)) {
$size = $row['productSize'];
$boom = explode(",", $size);
foreach ($boom as $row){
echo '<option value='.$row['id'].'>'.$row['sizeName'].'</option>';
}} ?>
但是仍然存在一个问题:需要显示sizeName而不是ID。 附言我是php新手,请原谅我这么简单的问题:)
答案 0 :(得分:0)
stages:
- initialize
- build
repo1 pull:
stage: initialize
script:
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.instance/group/repo1.git
repo2 pull:
stage: initialize
script:
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.instance/group/repo2.git
image1:
stage: build
script:
- cp repo1/ image1/
- cd image1
- docker build -t image1 --network=host .
- docker login -u gitlab-runner -p gitlab docker.registry
- docker push docker.registry/image1:latest
image2:
stage: build
script:
- cp repo2/ image2/
- cd image2
- docker build -t image2 --network=host .
- docker login -u gitlab-runner -p gitlab docker.registry
- docker push docker.registry/image2:latest
答案 1 :(得分:0)
<?php
$query=mysqli_query($con,"select size.id, size.sizeName,
products.productSize from size INNER JOIN products ON
size.id=products.productSize WHERE products.id='$pid'");
while($row = mysqli_fetch_assoc($query)) {
?>
<option value="<?php echo $row['size.id']; ?>"><?php echo $row['sizeName']; ?>/option>
<?php
}
?>