Jump to content

Recommended Posts

I'm trying to integrate my php code with a Javascript expandable/collapsible menu system (JS code available on request, it's large).  Basically, I need each  expandcontent('$IDENT') & div id=\"$IDENT\" to go up one number for each distinct category and tied to that category to operate the menu controls. I have tried nested for loops with no success. The closest I've gotten is with the code below and all it seems to control is the 1st item of the 1st category. I would greatly appreciate any help to steer me in the right direction.

$catmenu = mysql_query("SELECT subcategory, category FROM $DBTABLE1 ORDER BY category, subcategory");
while($row = mysql_fetch_array($catmenu))
{
$IDENT=$row['id'];
$CAT=$row['category'];
$SUBCAT=$row['subcategory'];

if ($CAT != $prev_row)
  {echo "<br><font face=\"Arial, Helvetica, sans-serif\" size=2><b><a onClick=\"expandcontent('$IDENT')\"><u>$CAT</u></a></b></font><br><div id=\"$IDENT\" class=\"switchcontent\">";
  }
$encCAT=htmlentities($CAT);
$encSUBCAT=htmlentities($SUBCAT);
  echo "  <font face=\"Arial, Helvetica, sans-serif\" size=2><a href=\"http://www.navi-gator.com/demo/bg-testing/sfm/products.php?cat=$encCAT&subcat=$encSUBCAT\">$SUBCAT</div></a></font>";
  $prev_row=$CAT;
}

Link to comment
https://forums.phpfreaks.com/topic/88244-integration-of-a-js-menu-within-php/
Share on other sites

Let me try asking this another way. I have categories (duplicate listings) that I need to get to single occurances (done that), then have each one tied a number starting at 1, stopping at whatever the highest number is in that set. Everything I've tried so far doesn't get the numbers to change. For example, my attempt below outputs just a 1 for every category. Obviously I'm doing something wrong or have the code in the wrong place, but don't know how I should set it up. Please, help!

	  $catmenu = mysql_query("SELECT subcategory, category FROM $DBTABLE1 ORDER BY category, subcategory");
$expcatmenu = mysql_query("SELECT DISTINCT category FROM $DBTABLE1 ORDER BY category");
$enumrows=mysql_num_rows($expcatmenu);
for($e = 1; $e <= $enumrows; $e++)
while($row = mysql_fetch_array($catmenu))
{

$CAT=$row['category'];
$SUBCAT=$row['subcategory'];

if ($CAT != $prev_row)
  {
  echo "<br><font face=\"Arial, Helvetica, sans-serif\" size=2><b><a onClick=\"expandcontent('$e')\"><u>$e $CAT</u></a></b></font><br><div id=\"$e\" class=\"switchcontent\">";
  }
$encCAT=htmlentities($CAT);
$encSUBCAT=htmlentities($SUBCAT);
  echo "  <font face=\"Arial, Helvetica, sans-serif\" size=2><a href=\"http://www.navi-gator.com/demo/bg-testing/sfm/products.php?cat=$encCAT&subcat=$encSUBCAT\">$SUBCAT</div></a></font>";
  $prev_row=$CAT;
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.