La primera consulta la hace bien y sin problemas.
Código:
P.D.: La conexion a la BD se hace asi:<div id="item-list"> <? $result = mysql_query("SELECT * FROM internet_shop WHERE id in (select idproducto from cestas where clave_sesion ='".$_SESSION['id']."')"); if(mysql_num_rows($result)!=0){ while($row=mysql_fetch_assoc($result)) { echo '<table width="100%" id="table_'.$row['id'].'"> <tr> <td width="15%"><img src="admin/uploads/'.$row['img'].'" alt="'.$row['name'].'" width="64" height="64" class="pngfix" /></td> <td width="50%">'.$row['name'].'</td> <td width="5%">'; $selected=mysql_query("SELECT q FROM cestas WHERE idproducto = ".$row['id']." and idcesta='".$_SESSION['id']."'") or die (mysql_error()); $row2=mysql_fetch_assoc($selected); echo "q: ".$row2->q; echo '<select name="'.$row['id'].'_cnt" id="'.$row['id'].'_cnt" onchange="change('.$row['id'].');">'; for($i=1;$i<=5;$i++){ if($i==$row2['q']) $sel="SELECTED"; else $sel=""; echo'<option '.$sel.' value="'.$i.'">'.$i.'</option>'; } echo'</select> </td> <td width="10%"><a href="#" onclick="removeb('.$row['id'].');return false;" class="remove">borrar</a></td> </tr> </table>'; } }?> </div>
Código:
$link = mysql_connect($db_host,$db_user,$db_pass,TRUE) or die('Unable to establish a DB connection'); mysql_select_db($db_database,$link);