Ver Mensaje Individual
  #2 (permalink)  
Antiguo 19/05/2016, 19:48
xoceunder
 
Fecha de Ingreso: junio-2012
Ubicación: En el Mundo
Mensajes: 766
Antigüedad: 12 años, 9 meses
Puntos: 10
Respuesta: duda con consulta mysq y php

Tengo esto en prueba

Código PHP:
Ver original
  1. $catsql=$mysqli->query("SELECT id,name FROM categories ORDER BY name ASC");
  2.        
  3.     $defcatsql=$mysqli->query("SELECT category_id FROM category_user WHERE user_id='1' ORDER BY category_id ASC");
  4.     $defcatres=$defcatsql->fetch_array();
  5.  
  6. <select name="category[]" id="category" class="category-multiple" multiple="multiple">
  7. <?php                                               while($catres=$catsql->fetch_array()) {
  8.     foreach($defcatres as $defcatid) {
  9.         if($defcatid==$catres["id"]) {
  10.                                                       print("<option value=\"".$catres["id"]."\" selected>".$catres["name"]."</option>");
  11.         }else{
  12.           print("<option value=\"".$catres["id"]."\">".$catres["name"]."</option>");   
  13.         }
  14.     }                                                                                                   }                                          ?>
  15.                                             </select>