Jump to content

Integration of a JS menu within PHP


stmosaic

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;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.