Forum Moderators: coopster
[3]
$cat_query = mysql_query($Csql) or die(mysql_error());
// Count the rows
$cat_num = mysql_num_rows($cat_query);
if($cat_num > 0) {
$x=0;
while($cat = mysql_fetch_array($cat_query)) {
$x=$x+1;
$chop = explode("\\",$cat["Category"]);
echo "$chop[0] $chop[1] $chop[2] $chop[3] $chop[4] <br />";
}[/3]
DESIRED OUTPUT:
Disposables
Coffee Service
Coffee
Filters
Unwrapped
Wrapped
$cat_query = mysql_query($Csql) or die(mysql_error());
// Count the rows
$cat_num = mysql_num_rows($cat_query);
if($cat_num > 0) {
$x=0;
while($cat = mysql_fetch_array($cat_query)) {
$x=$x+1;
$chop = explode("\\",$cat["Category"]);
$chop = array_unique($chop);
}
foreach ($chop as $chopped)
{
echo $chopped."<br />";
}
Although I may have read that wrong about what you want.
dc
$new = array();
$cat_query = mysql_query($Csql) or die(mysql_error());
// Count the rows
$cat_num = mysql_num_rows($cat_query);
if($cat_num > 0) {
$x=0;
while($cat = mysql_fetch_array($cat_query)) {
$x=$x+1;
$chop = explode("\\",$cat["Category"]);for ($i=0; $i<count($chop); $i++)
{
if (!in_array($chop[$i], $new))
{
$new[] = $chop[$i];
}
}
foreach ($new as $cats)
{
echo $cats."<br>";
}
Does that work?
dc
$new = array();
$cat_query = mysql_query($Csql) or die(mysql_error());
// Count the rows
$cat_num = mysql_num_rows($cat_query);
if($cat_num > 0) {
$x=0;
while($cat = mysql_fetch_array($cat_query)) {
$x=$x+1;
$chop = explode("\\",$cat["Category"]);for ($i=0; $i<count($chop); $i++)
{
if (!in_array($chop[$i], $new))
{
$new[] = $chop[$i];
}
unset ($chop);
}
foreach ($new as $cats)
{
echo $cats."<br>";
}
dc