Q:

How to put PHP while loop inside a HTML option menu? 

I have downloaded a shopping cart for my site, 
It has a PHP file to fill out the basket.  the basket will show added items in rows, here is the code : 
<? php

define('INCLUDE_CHECK',1);
require "XXXXX/XXXXX.php";

if(!$_POST['img']) die("There is no such product!"); 

$img=mysql_real_escape_string(end(explode('/',$_POST['img'])));
$row=mysql_fetch_assoc(mysql_query("SELECT * FROM XXXXXX WHERE img='".$img."'")); 
$prsize=mysql_fetch_assoc(mysql_query("SELECT * FROM BBBBBB WHERE id='".$row['id']."'")); 
echo '{status:1,id:'.$row['id'].',price:'.$row['price'].',txt:\'\
\
<table width="100%" id="table_'.$row['id'].'">\
<tr>\
<td width="60%">'.$row['name'].'</td>\
<td width="10%">$'.$row['price'].'</td>\
<td width="15%"><select name="'.$row['id'].'_cnt" id="'.$row['id'].'_cnt" onchange="change('.$row['id'].');">\
<option value="1">1</option>\
<option value="2">2</option>\
<option value="3">3</option></slect>\
\
</td>\

<td width="15%"><select name="'.$prsize['id'].'_cnt" id="'.$prsize['id'].'_cnt" onchange="change('.$prsize['id'].');">\

I need to put this 
    while($item = mysqli_fetch_array($result))
            {

here to make a dynamic select menu for the size
<option value="'.$prsize['id'].'">'.$prsize['id'].'</option>\

end while
    }

\
</td>\

<td width="15%"><a href="#" onclick="remove('.$row['id'].');return false;" class="remove">remove</a></td>\
   </tr>\
  </table>\'}';
  ? >

but I couldn't figure it out how to put the PHP while in there, I have tried to use "" or '' but no luck.   
How should I quote the PHP while inside this HTML code? 
Thanks

A:

Maybe something like this:
$options = "";
while($item = mysqli_fetch_array($result))
    $options .= "<option value=\"$item[id]\">$item[id]</option>\\\n";

and then just use it
echo '{status:1,id:'.$row['id'].',price:'.$row['price'].',txt:\'\
\
<table width="100%" id="table_'.$row['id'].'">\
<tr>\
<td width="60%">'.$row['name'].'</td>\
<td width="10%">$'.$row['price'].'</td>\
<td width="15%"><select name="'.$row['id'].'_cnt" id="'.$row['id'].'_cnt" onchange="change('.$row['id'].');">\
'.$option. '</select>\
...

Or you can simply break your echo in two and put your loop between the calls:
echo '{status:1,id:'.$row['id'].',price:'.$row['price'].',txt:\'\
\
<table width="100%" id="table_'.$row['id'].'">\
<tr>\
<td width="60%">'.$row['name'].'</td>\
<td width="10%">$'.$row['price'].'</td>\
<td width="15%"><select name="'.$row['id'].'_cnt" id="'.$row['id'].'_cnt" onchange="change('.$row['id'].');">\
';
while($item = mysqli_fetch_array($result))
    echo "<option value=\"$item[id]\">$item[id]</option>\\\n";
echo '</select>\
\
</td>\
...

Btw, your </select> is missing one "e" (it says </slect>).