<?php
foreach( $_SESSION['post']['test_id'] as $value){
$sql_lab = "SELECT * FROM labs WHERE status = 1";
<?php
if ($result_lab->num_rows > 0) {
while($row = $result_lab->fetch_assoc()) {
if($result->num_rows > 0) {
while($row1 = $result->fetch_assoc()) { ?>
<input type="radio" name="lab" id="<?php echo $row1['lab_id'] ?>" value="<?php echo $row['lab_name'] . ',' . $row1['price'] ?>" ><?php echo $row['lab_name'];?>
<script>
var elements = document.getElementById("<?php echo $row1['lab_id'] ?>").value; console.log(elements);
</script>
<?php
$price = $row1['price'];
echo $price . "</br>";
break;
}
}
}
}
} ?>
<button type="submit" name="submit" value="submit">Submit</submit>
</form>
我希望输出6个不同的值,例如在使用javascript的控制台中,在php中给出正确的输出
lab_name1,price1,lab_name2,price2,lab_name3,price3,lab_name1,price4,lab_name2,price5,lab_name3,price6
但显示
lab_name1,price1,lab_name2,price2,lab_name3,price3,lab_name1,price1,lab_name2,price2,lab_name3,price3。