2
I was able to separate some values from a column in a table in Phpmyadmin through some tips and I did this:
mysql_select_db($database_conexao, $conexao);
if ($dep != "" and $sub != "") {
$query_rsPesquisa = "SELECT * FROM `produtos` WHERE id_departamento = $dep AND id_subdepartamento = $sub";
} else {
$query_rsPesquisa = "SELECT * FROM `produtos` WHERE id_departamento = $dep";
}
$rsPesquisa = mysql_query($query_rsPesquisa, $conexao) or die(mysql_error());
$row_rsPesquisa = mysql_fetch_assoc($rsPesquisa);
$totalRows_rsPesquisa = mysql_num_rows($rsPesquisa);
$string = $row_rsPesquisa['id_subfiltro'];
$array = explode(',', $string);
And then, to get a description of each id in a specific table and show on my page, I did this:
<?php
if ($dep != "" and $sub != "") {
foreach ($array as $valores) {
mysql_select_db($database_conexao, $conexao);
$query_rsSub = "SELECT * FROM subfiltro WHERE id_subfiltro = $valores";
$rsSub = mysql_query($query_rsSub, $conexao) or die(mysql_error());
$row_rsSub = mysql_fetch_assoc($rsSub);
$totalRows_rsSub = mysql_num_rows($rsSub);
$descProd = $row_rsSub['descricao'];
echo "<ul class='menu2'>
<li><a href='#'>$descProd</a></li>
<li class='current-menu-item'></li>
</ul>";
}
}
?>
But what’s weird is that my first select
not getting all the values from my column id_subfilter, it seems that in the first, see the image below:
This is the page: Developing page
The values that in this case need to rescue would 8,2,61,155,6,17,16,176,117.
But it’s returning to me:
Array ( [0] => 8 [1] => 2 [2] => 61 [3] => 155 [4] => 6 [5] => 17 )
Running this query in phpMyAdmin, the value of this column is also cut?
– Lucas
Hello @Lucas, no, the result appears full.
– adventistapr
In my view, have you solved right? Post here the resolution.
– Lollipop
Hello Lollipop, I managed to resolve yes, but I still have some doubts that need to be properly addressed.
– adventistapr
Just a hint: mysql_* functions are obsolete since PHP 5.5. Prefer to use Mysqli or PDO. See more here: http://www.ultimatephp.com.br/php-por-que-nao-utilizar-funcoes-mysql
– Beraldo