PHP Language Comparison

Asked

Viewed 28 times

0

I need to compare products in the table if the language esp and ing are filled...

When I register the product it registers as the language 1(by).

Then the customer has to register the 2(ing) and 3(esp).

$pdo = db_connect(); 
$listar = $pdo->prepare("SELECT * FROM produtos WHERE ativo = 1 AND id_produto = :cod");
$listar->bindParam(':cod', $cod);
$listar->execute();
$dados = $listar->fetch(PDO::FETCH_OBJ);

$produto = $dados->id_produto; 
$idioma = $dados->idioma;

Here’s the code to call the buttons.

<tr>
<td><strong><?php echo $dados->titulo;?></strong></td>                              
<?php if ($dados->idioma == '2'){?>
<td><a href="painel.php?p=produtos-idiomas-cadastrar&cod=<?php echo $dados->id_produto; ?>&img=<?php echo $dados->produto_imagem; ?>"><button type="submit" class="btn btn-success"><i class="fa fa-plus"></i> Cadastrar</button></a></td>
<?php } else { ?>
<td><a href="painel.php?p=produtos-idioma-editar&cod=<?php echo $dados->id;?>"><span class="glyphicon glyphicon-pencil" aria-hidden="true" title="Editar"></span></a></td>       
<?php { ?>

<?php if ($dados->idioma == '3'){ ?>
<td><a href="painel.php?p=produtos-idiomas-cadastrar&cod=<?php echo $dados->id_produto; ?>&img=<?php echo $dados->produto_imagem; ?>"><button type="submit" class="btn btn-success"><i class="fa fa-plus"></i> Cadastrar</button></a></td>
<?php } else { ?>                        
<td><a href="painel.php?p=produtos-idioma-editar&cod=<?php echo $dados->id;?>&idioma=3"><span class="glyphicon glyphicon-pencil" aria-hidden="true" title="Editar"></span></a></td>
<?php } ?>
</tr>

inserir a descrição da imagem aqui

In the image I have the products 603, 544, 292 that are only in Portuguese... Product 10 is in 3 languages (1-per, 2-ing and 3-esp)...

If the product is registered in language 2 and 3 I want the edit button to appear. If the product is not registered in language 2 and 3 appears the sign up button.

  • Right... and what’s the problem?

  • If the product is registered in language 2 and 3 the edit button appears. If the product is not registered in language 2 and 3 appears the sign up button.

  • Language is a string?

  • This comes from another table

  • No, I don’t think you understand. The "language" column is a string?

  • Yes it’s a string....

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.