Ver Mensaje Individual
  #3 (permalink)  
Antiguo 28/01/2015, 15:04
Avatar de Josantonius
Josantonius
 
Fecha de Ingreso: enero-2015
Mensajes: 15
Antigüedad: 9 años, 3 meses
Puntos: 0
Respuesta: Guardar 2 consultas SQL en un array y leerlo con foreach

Muchas gracias por tu rápida respuesta enlinea777.

El error que me da es el siguiente:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON wp_posts.post_status = 'publish') AND ON wp_posts.ID = wp_postmeta.post_id) A' at line 4

Código PHP:
$resultados mysql_query("SELECT wp_posts.ID,wp_posts.post_title,wp_posts.post_status,wp_postmeta.meta_value
FROM wp_posts INNER JOIN wp_postmeta
ON wp_posts.post_type = 'product' AND
ON wp_posts.post_status = 'publish') AND
ON wp_posts.ID = wp_postmeta.post_id) AND
ON wp_postmeta.meta_key = '_product_attributes')]"
) or die(mysql_error());


while (
$eventos mysql_fetch_array($resultados)) { 

        
$datos_seleccionados[] = array(
        
'nombre' => $eventos['wp_posts.post_title'],
        
'status' => $eventos['wp_posts.post_status'],
        
'ID' => $eventos['wp_posts.ID']);
    }


$i 0;
foreach (
$datos_seleccionados as $eventos){
    
$i++;
    echo 
'ID ' $eventos['ID'] . ' NOMBRE: ' $eventos['nombre'] . ' STATUS: ' $eventos['status'] .  '<br>';