while loop inside foreach loop in PHP

378

i want to make a table that on the first column consist of name from database and on the second column consist of value from an array. this is what i have

<table>
    <tr> 
        <?php $arr=array(3,5,2,4,1);                            
        $name= mysql_query("SELECT name FROM table")
        foreach ($arr as $rs){                          
            while($n=mysql_fetch_array($name)){ ?>                      
                <td><?=$n['name']?></td>
                <td><?=$rs?></td>
    </tr>
    <?php   }   }   ?>                          
</table>

i need an output like

name_a 3
name_b 5
name_c 2
name_d 4
name_e 1

thank you in advance.

People are also looking for solutions to the problem: php - delete only first slashes from url/string

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.