PHP - output associate array into HTML
s with labels/headings

前端 未结 2 1036
猫巷女王i
猫巷女王i 2021-01-27 00:31

I have a PHP function that returns a single row from a localhost MySQL table like so:



        
相关标签:
2条回答
  • 2021-01-27 01:06

    You can use foreach

    <?php foreach ($row as $key => $val): ?> 
        <p><strong><?php echo $key; ?>:</strong></p> 
        <p>
            <?php
                //output relevant attribute
                //of query run on page load
                echo $val;
            ?>
        </p>
    <?php endforeach; ?>
    
    0 讨论(0)
  • 2021-01-27 01:24

    I didn't understand the question very well but I think I understand what you need.

    Use while to iterate trough each row.

    while($row = $resultDesc->fetch_assoc())
    {
        echo '<p><strong>Description:</strong></p> ';
        echo '<p>'. $row['description'] . '</p>';
    }
    

    That's not the exact solution but atleast shows you the path.

    0 讨论(0)
提交回复
热议问题