简体   繁体   中英

single line break In while loop

I would like to have a single <br> in my while loop. If I add the <br> I get a <br> for single item, what I want is that only <br> is shown between <img> and <button> . So not for every button separately. Can someone help me?

<?php
if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) 
    {
?>

<img src="<?php echo $result_question['img'];?>">

<input type="button" id="<?php echo $row["answer_id"];?>" next_question_id="<?php echo $row["next_question_id"];?>" value="<?php echo $row["answer_text"];?>" onclick=myFunction2((this.id));>

<?php   
    }
} 
$conn->close();
?>

is this what you mean?

<?php
if ($result->num_rows > 0) {
    $c = 0;
    // output data of each row
    while($row = $result->fetch_assoc()) 
    {
?>

<img src="<?php echo $result_question['img'];?>">
<?php if ($c == 0){ ?><br/><?php } ?> 

<input type="button" id="<?php echo $row["answer_id"];?>" next_question_id="<?php echo $row["next_question_id"];?>" value="<?php echo $row["answer_text"];?>" onclick=myFunction2((this.id));>

<?php  
    $c++; 
    }
} 
$conn->close();
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM