<?php
$query = "SELECT img_path FROM oc_product_color Order by color_id" ;
$result = mysql_query($query) ;
$counter = 0 ;
$z=0;
while($row = mysql_fetch_assoc($result))
{
$color[$counter] = $row['img_path'];
$counter = $counter + 1;
}
?>
<div>
<font size="4">Choose Your Product Color:</font>
</div>
<style>
label > input{ /* HIDE RADIO */
visibility: hidden;
position: absolute;
}
label > input + img{ /* IMAGE STYLES */
cursor:pointer;
border:2px solid transparent;
}
label > input:checked + img{ /* (RADIO CHECKED) IMAGE STYLES */
border:2px solid #A8813E;
}
</style>
<style>
.grow img {
height: 24px;
width: 24px;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
.grow img:hover {
width: 50px;
height: 50px;
}
</style>
<div>
<?
if($counter>0)
{
for($z=0;$z<$counter;$z++)
{
?>
<tr >
<?
if($z<$counter)
{
?>
<label class="grow pic">
<input type="radio" name="color" checked="checked" value="small" onclick = />
<img src=<?php echo $color[$z];?> width="16px" height="16px" />
</label>
<?
}
?>
</tr>
<? }
} ?>
</a></div>
</div>
<label for="color"><img src = "<?php echo $color[$z] ?>"></label>
</div>
<br>
</div>
亲爱的Stackoverflow
我试图获取与之关联的图像路径并显示它,但这是徒劳的:
<label for="color"><img src = "<?php echo $color[$z] ?>"></label>
我是php的新手并且设法完成了这段代码
任何帮助将不胜感激
抱歉我的英文不好
谢谢&amp;问候
Akki2401
答案 0 :(得分:0)
我不确定你在问什么,但我觉得这就是你在寻找的东西!试试这个!
<div class="radio-buttons">
<input type="radio" name="rGroup" value="1" id="r1" checked="checked" />
<label class="radio-label" for="r1"></label>
<input type="radio" name="rGroup" value="2" id="r2" />
<label class="radio-label" for="r2"></label>
<input type="radio" name="rGroup" value="3" id="r3" />
<label class="radio-label" for="r3"></label>
</div>
和Css
.radio-buttons .radio-label{
background-color:#E8C504;
display:inline-block;
width:40px;
height:40px;
border-radius:40px;
}
.radio-buttons input[type=radio]{
display:none
}
.radio-buttons input[type=radio]:checked + .radio-label{
background-color:#241009
}