Hello everyone, I hope you can help me with this problem. Here's the deal:
I have this code:
<?php
$artic = $_GET['art'];
include("config.php");
$result=$db->query("SELECT * FROM equiva WHERE ((codigo1 LIKE $artic) OR (codigo2 LIKE $artic))");
while ($row=$result->fetch_array(MYSQLI_ASSOC)){
if($artic == $row['codigo1']){
$codigoart = $row['codigo2'];}
else {$codigoart = $row['codigo1'];}
$resultados=$db->query("SELECT id_art,denom2,exist,marca FROM articulos WHERE id_art LIKE $codigoart");
$row2 = $resultados->fetch_array(MYSQLI_ASSOC);
$mark = $row2['marca'];
$cadena = $row2['id_art'];
$res_marca = $db->query("SELECT id_marca,marca FROM marcas WHERE id_marca LIKE $mark");
$row1 = $res_marca->fetch_array(MYSQLI_ASSOC);
?>
<tbody>
<tr>
<td valign="middle"><?php echo $codigoart;?> </td>
<td valign="middle"><?php echo $row1['marca'];?> </td>
<td valign="middle"><?php echo $row2['denom2'];?> </td>
<td> <a target="_blank" href="verequiv.php?art=<?php echo $cadena;?>" ><img src="/images/articulos/<?php echo $nombre;?>.jpg"></a></td>
</tr>
</tbody>
<?php
I try to get from the equiv table (that has only 2 columns, codigo1 and codigo2) those records same to $artic and dump on an array. So far so good.
Walking through this array, and compare values of the same with a query, apparently it only resolved the first pass, then no more. If I check if($resultados=$db->query("SELECT id_art,denom2,exist,marca FROM articulos WHERE id_art LIKE $codigoart")), the first time it is true but then is false.
Please, any ideas is welcome because I am stuck here. thank you!
PD: Obviously sorry for my English ;-)