5
I am trying to list a certain product category. example.
$consulta = $pdo->prepare("SELECT * FROM msg where tema = :tema;");
$s = 'mensagens-de-aniversario';
$consulta->bindParam(":tema", $s, PDO::PARAM_STR);
$consulta->execute();
while ($linha = $consulta->fetch(PDO::FETCH_ASSOC)){
if($linha['voz'] == 'vozfeminina'){
echo "<p>".$linha['voz']." A</p>";
}
if($linha['voz'] == 'vozmasculina'){
echo "<p>".$linha['voz']." B</p>";
}
}
This listing thus:
vozfeminina A, vozfeminina A, vozmasculina B, vozmasculina B
Would have a way when do this query list all products in order:
"vozfeminina A" | "vozmasculina B" | "vozfeminina A" | "vozmasculina B"...
I am using mysql PDO connection.
But what order would that be? I do not know if it was the example, but it seems that it is wanting to intermediate?
– Papa Charlie
That same interim result. Would be like this: I have 4 products X and 4 product Y when listing I would like it to stay like this product X, Y, X, Y, X, Y
– wildson
But there is only one pair (female A, male A, female B, male B, female C, male C) which would result in
fem-A, masc-A, fem-B, masc-B
. Would that be?– Papa Charlie
We’re almost there. That’s how it would be. in the same table has female product and male product, the idea is to list thus product-a, product,b product,a product,b. the above code is listing product a, product a, product b, product b,
– wildson
I am doing some tests with GROUP by but shows only two results. and already with Union shows the same result above.
– wildson
It seems to me Pivot
– Maicon Carraro