Jump to content

stmosaic

Members
  • Posts

    44
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

stmosaic's Achievements

Member

Member (2/5)

0

Reputation

  1. Still working on this bear. I've reworked my FOR loop, but it still does not display the data. I know I've done something wrong, but I can't see what it is. $current_sub = $row['Subcategory']; $sql_sub = mysql_query("SELECT * FROM $DBTABLE WHERE (CLSfolder='$selectedCLSfolder') && (Active='Y') && (Subcategory = '$current_sub') ORDER BY Bname"); $result_sub = mysql_fetch_array($sql_sub); for ($result_sub = 0; $result_sub < $sql_sub; $result_sub++){ if ($result_sub['udURL'] == ""){ echo "<font face=\"Verdana\">{$result_sub['Bname']}</font>"; }else{ echo "<a href=\"http://{$result_sub['udURL']}\"><font face=\"Verdana\">{$result_sub['Bname']}</font></a>"; } echo "<br>"; if ($result_sub['Slogan'] != '') { echo "<font face=\"Verdana\" size=2><i>{$result_sub['Slogan']}</i></font><br>"; } if (($result_sub['TFPhone'] != "") && ($result_sub['LPhone'] != "")){echo "<font face=\"Verdana\" size=2>{$result_sub['TFPhone']} / {$result_sub['LPhone']}<br></font>"; }else{ echo "<font face=\"Verdana\" size=2>{$result_sub['TFPhone']} {$result_sub['LPhone']}<br></font>"; } if ($result_sub['CLSmap'] == 'Y'){ echo "<font face=\"Verdana\" size=2><a href=\"maps/maps.php?IDENT={$result_sub['ID']}\" target=\"_blank\">Map/Directions</a></font>";} }//end of for loop ///END of data to be shown for each business with the same Subcategory
  2. Mr. Marcus, thank you for responding! That's part of what is giving me a fit. I want every new Subcategory to be in a new column, but for a Subcategory that has 2 or more listings, they need to be in just one column. The html part is correct in that it gives me a new column per subcategory when there is just one listing, which is what I want. It's when there is more than one listing per Subcategory that is the problem. That's why I posted the part of the code that I think I need to loop through to accomplish this. Any other suggestions?
  3. Been working on this script for 5 days, got the duplicate Subcategory display issue fixed, but the solution has caused a new problem that I've been pulling my hair out over. When the Subcategory is showing, I'm trying to get all the selected data from from each listing that has the same Subcategory to be in the same column. Right now, it works fine as long as there is only one listing, but if there are 2 or more it puts the data in the next column. Pretty sure I need to loop through the data until there are no more listings for that Subcategory. But I have tried a for loop, a foreach (which I've never been able to get working) and a nested while loop, all with funky results. Not sure if I'm putting it in the wrong place or if I'm constructing it wrong, But I could sure use some help with this! Code I need to loop through ////Data to shown for each business listing of the same Subcategory if ($row['udURL'] == ""){ echo "<font face=\"Verdana\">{$row['Bname']}</font>"; }else{ echo "<a href=\"http://{$row['udURL']}\"><font face=\"Verdana\">{$row['Bname']}</font></a>"; } echo "<br>"; if ($row['Slogan'] != '') { echo "<font face=\"Verdana\" size=2><i>{$row['Slogan']}</i></font><br>"; } if (($row['TFPhone'] != "") && ($row['LPhone'] != "")){echo "<font face=\"Verdana\" size=2>{$row['TFPhone']} / {$row['LPhone']}<br></font>"; }else{ echo "<font face=\"Verdana\" size=2>{$row['TFPhone']} {$row['LPhone']}<br></font>"; } if ($row['CLSmap'] == 'Y'){ echo "<font face=\"Verdana\" size=2><a href=\"maps/maps.php?IDENT={$row['ID']}\" target=\"_blank\">Map/Directions</a></font>"; } ////END of data to be shown for each business with the same Subcategory My for loop attempt: if(($last_subcategory != '') && ($last_subcategory == $row['Subcategory'])){ $numsubcat = mysql_query("SELECT * FROM $DBTABLE WHERE (Subcategory = '$last_subcategory') && (Active='Y')"); $ubname = mysql_query("SELECT Bname, udURL, SLogan, TFPhone, LPhone, CLSmap, ID FROM $DBTABLE WHERE (Subcategory = '$last_subcategory') && (Active='Y') ORDER BY Subcategory, Bname"); } $subrow = mysql_fetch_array($ubname); for ($srow = 0; $srow < $numsubcat; $srow++) {//listing code} The code as it exists right now (you can see how it is displaying at http://www.citylifesites.com/services.php?CLSfolder=pinehurst-nc&City=Pinehurst&State=NC) $selectedCLSfolder=$_GET['CLSfolder']; $selectedCity=$_GET['City']; $selectedState=$_GET['State']; $last_subcategory = ''; $last_category = ''; // initialize variable to detect a change in the category. Set to a value that will never exist as data $columns = 3; // number of columns in a table row $count = 0; // counter to track current column in the table row $sub = mysql_query("SELECT * FROM $DBTABLE WHERE (CLSfolder='$selectedCLSfolder') && (Active='Y') ORDER BY Category, Subcategory"); echo "<table width=\"98%\" align=\"center\">\n"; // overall table (whatever you current have...) while($row = mysql_fetch_array($sub)){ // check for a new Category and output the heading when the Category changes - if($last_category != $row['Category']){ // if $count is not 0, finish any previous partial row/section of Subcategory data if($count != 0){ // finish the current row while($count % $columns != 0){ echo "<td> </td>"; $count++; } // close the row/section echo "</tr>\n</table>\n"; } // output the Category heading echo "<tr><td colspan=3> </td></tr><tr><td valign=\"top\" bgcolor=\"#FDD9BA\">"; echo "<font face=\"Verdana\"><b>{$row['Category']}</b></font></td></tr>\n"; $last_category = $row['Category']; // remember the new Category $count = 0; // reset the count (new set of rows) } // at this point, you have Subcategory data to display // if $count == 0, need to start a new section for the Subcategory data if($count == 0){ echo "<tr><td><TABLE width=\"100%\" border=0 align=\"center\">\n<tr>"; } elseif($count % $columns == 0) { // if count is not 0 and $count % $columns == 0, need to finish previous row and start a new one echo "</tr>\n<tr>"; } // display the actual Subcategory data - echo "<td width=\"33%\" align=\"left\" valign=\"top\">"; if ($row['Subcategory'] == 'None'){ $row['Subcategory']="View All ".$row['Category'];} if($last_subcategory != $row['Subcategory']){ echo "<ul id=\"{$row['Subcategory']}\" class=\"treeview\"> <font face=\"Verdana\" size=2><li><b>{$row['Subcategory']}</b></font><br><br> <ul>"; } ////Data to shown for each business listing of the same Subcategory if ($row['udURL'] == ""){ echo "<font face=\"Verdana\">{$row['Bname']}</font>"; }else{ echo "<a href=\"http://{$row['udURL']}\"><font face=\"Verdana\">{$row['Bname']}</font></a>"; } echo "<br>"; if ($row['Slogan'] != '') { echo "<font face=\"Verdana\" size=2><i>{$row['Slogan']}</i></font><br>"; } if (($row['TFPhone'] != "") && ($row['LPhone'] != "")){echo "<font face=\"Verdana\" size=2>{$row['TFPhone']} / {$row['LPhone']}<br></font>"; }else{ echo "<font face=\"Verdana\" size=2>{$row['TFPhone']} {$row['LPhone']}<br></font>"; } if ($row['CLSmap'] == 'Y'){ echo "<font face=\"Verdana\" size=2><a href=\"maps/maps.php?IDENT={$row['ID']}\" target=\"_blank\">Map/Directions</a></font>"; } ////END of data to be shown for each business with the same Subcategory echo"</li></ul> </li></ul>"; echo " </td> <script type=\"text/javascript\"> ddtreemenu.createTree(\"{$row['Subcategory']}\", false) </script> "; $last_subcategory = $row['Subcategory']; $count++; // count one Subcategory } // end of while loop // if $count is not 0, finish any previous partial row/section of Subcategory data if($count != 0){ while($count % $columns != 0){ echo "<td> </td>"; $count++; } // close the row/section echo "</tr>\n</table>"; } echo "</table>\n"; // close overall table
  4. Still working on this one, I just tried yet another option, and now all I get is Array rather than the Subcategory. Really getting frustrated with this one. Please, can anyone help? Here is the modified code: $last_category = ''; // initialize variable to detect a change in the category. Set to a value that will never exist as data $columns = 3; // number of columns in a table row $count = 0; // counter to track current column in the table row $sub = mysql_query("SELECT * FROM $DBTABLE WHERE (CLSfolder='$selectedCLSfolder') && (Active='Y') ORDER BY Category, Subcategory"); echo "<table width=\"98%\" align=\"center\">\n"; // overall table (whatever you current have...) while($row = mysql_fetch_array($sub)){ // ADDED $subcategories[] = $row['subcategory']; $newData[] = array_unique($subcategories); //END ADDED // check for a new Category and output the heading when the Category changes - if($last_category != $row['Category']){ // if $count is not 0, finish any previous partial row/section of Subcategory data if($count != 0){ // finish the current row while($count % $columns != 0){ echo "<td> </td>"; $count++; } // close the row/section echo "</tr>\n</table>\n"; } // output the Category heading echo "<tr><td colspan=3> </td></tr><tr><td valign=\"top\" bgcolor=\"#FDD9BA\">"; echo "<font face=\"Verdana\"><b>{$row['Category']}</b></font></td></tr>\n"; $last_category = $row['Category']; // remember the new Category $count = 0; // reset the count (new set of rows) } // at this point, you have Subcategory data to display // if $count == 0, need to start a new section for the Subcategory data if($count == 0){ echo "<tr><td><TABLE width=\"100%\" border=0 align=\"center\">\n<tr>"; } elseif($count % $columns == 0) { // if count is not 0 and $count % $columns == 0, need to finish previous row and start a new one echo "</tr>\n<tr>"; } // display the actual Subcategory data - echo "<td width=\"25%\" align=\"left\" valign=\"top\">"; if ($row['Subcategory'] == 'None'){ if ($row['udURL'] == ""){ echo "<font face=\"Verdana\">{$row['Bname']}</font>"; }else{ echo "<a href=\"http://{$row['udURL']}\"><font face=\"Verdana\">{$row['Bname']}</font></a>"; } echo" <br>"; if ($row['Slogan'] != '') { echo "<font face=\"Verdana\" size=2><i>{$row['Slogan']}</i></font><br>"; } if (($row['TFPhone'] != "") && ($row['LPhone'] != "")){echo "<font face=\"Verdana\" size=2>{$row['TFPhone']} / {$row['LPhone']}<br></font>"; }else{ echo "<font face=\"Verdana\" size=2>{$row['TFPhone']} {$row['LPhone']}<br></font>"; } if ($row['CLSmap'] == 'Y'){ echo "<font face=\"Verdana\" size=2><a href=\"maps/maps.php?IDENT={$row['ID']}\">Map/Directions</a></font>"; } }else{ //MODIFIED 1 echo "<ul id=\"$newData\" class=\"treeview\"> <font face=\"Verdana\" size=2><li><b>$newData</b></font><br><br> //END MODIFIED 1 <ul>"; if ($row['udURL'] == ""){ echo "<font face=\"Verdana\">{$row['Bname']}</font>"; }else{ echo "<a href=\"http://{$row['udURL']}\"><font face=\"Verdana\">{$row['Bname']}</font></a>"; } echo "<br>"; if ($row['Slogan'] != '') { echo "<font face=\"Verdana\" size=2><i>{$row['Slogan']}</i></font><br>"; } if (($row['TFPhone'] != "") && ($row['LPhone'] != "")){echo "<font face=\"Verdana\" size=2>{$row['TFPhone']} / {$row['LPhone']}<br></font>"; }else{ echo "<font face=\"Verdana\" size=2>{$row['TFPhone']} {$row['LPhone']}<br></font>"; } if ($row['CLSmap'] == 'Y'){ echo "<font face=\"Verdana\" size=2><a href=\"maps/maps.php?IDENT={$row['ID']}\">Map/Directions</a></font>"; } echo"</li></ul> </li></ul> <script type=\"text/javascript\"> // MODIFIED 2 ddtreemenu.createTree(\"$newData\", false) //END MODIFIED 2 </script>"; } echo " </td>"; $count++; // count one Subcategory } // end of while loop // if $count is not 0, finish any previous partial row/section of Subcategory data if($count != 0){ while($count % $columns != 0){ echo "<td> </td>"; $count++; } // close the row/section echo "</tr>\n</table>"; } echo "</table>\n"; // close overall table
  5. I've written some code that works about 90% of the way, but have run into an issue that has me stumped. I'm displaying Categories & Subcategories from a database intertwined with a JS expand & contract script. Everything works except that when there is more than one entry in a Subcategory, I get that Subcategory listed twice, which then breaks my JS. I know the solution to the JS end is to get the Subcategory only once, but implementing in has me pulling my hair out. You can view my semi-working sample here http://www.citylifesites.com/services.php?CLSfolder=pinehurst-nc&City=Pinehurst&State=NC, notice the Category Automotive where the Subcategory Tires is shown twice. I've tried a couple of different approaches, GROUP BY, Selecting disctinct Subcategory, array unique function (I may have messed up the syntax when calling the array later in the code as that tends to confuse me), but none have worked. I would appreciate any suggestions! $last_category = ''; // initialize variable to detect a change in the category. Set to a value that will never exist as data $columns = 3; // number of columns in a table row $count = 0; // counter to track current column in the table row $sub = mysql_query("SELECT * FROM $DBTABLE WHERE (CLSfolder='$selectedCLSfolder') && (Active='Y') ORDER BY Category, Subcategory"); echo "<table width=\"98%\" align=\"center\">\n"; // overall table (whatever you current have...) while($row = mysql_fetch_array($sub)){ // check for a new Category and output the heading when the Category changes - if($last_category != $row['Category']){ // if $count is not 0, finish any previous partial row/section of Subcategory data if($count != 0){ // finish the current row while($count % $columns != 0){ echo "<td> </td>"; $count++; } // close the row/section echo "</tr>\n</table>\n"; } // output the Category heading echo "<tr><td colspan=3> </td></tr><tr><td valign=\"top\" bgcolor=\"#FDD9BA\">"; echo "<font face=\"Verdana\"><b>{$row['Category']}</b></font></td></tr>\n"; $last_category = $row['Category']; // remember the new Category $count = 0; // reset the count (new set of rows) } // at this point, you have Subcategory data to display // if $count == 0, need to start a new section for the Subcategory data if($count == 0){ echo "<tr><td><TABLE width=\"100%\" border=0 align=\"center\">\n<tr>"; } elseif($count % $columns == 0) { // if count is not 0 and $count % $columns == 0, need to finish previous row and start a new one echo "</tr>\n<tr>"; } // display the actual Subcategory data - echo "<td width=\"25%\" align=\"left\" valign=\"top\">"; if ($row['Subcategory'] == 'None'){ if ($row['udURL'] == ""){ echo "<font face=\"Verdana\">{$row['Bname']}</font>"; }else{ echo "<a href=\"http://{$row['udURL']}\"><font face=\"Verdana\">{$row['Bname']}</font></a>"; } echo" <br>"; if ($row['Slogan'] != '') { echo "<font face=\"Verdana\" size=2><i>{$row['Slogan']}</i></font><br>"; } if (($row['TFPhone'] != "") && ($row['LPhone'] != "")){echo "<font face=\"Verdana\" size=2>{$row['TFPhone']} / {$row['LPhone']}<br></font>"; }else{ echo "<font face=\"Verdana\" size=2>{$row['TFPhone']} {$row['LPhone']}<br></font>"; } if ($row['CLSmap'] == 'Y'){ echo "<font face=\"Verdana\" size=2><a href=\"maps/maps.php?IDENT={$row['ID']}\">Map/Directions</a></font>"; } }else{ //THIS SEEMS TO BE THE PROBLEM AREA - STARTS THE SUBCATEGORY DATA OUTPUT echo "<ul id=\"{$row['Subcategory']}\" class=\"treeview\"> <font face=\"Verdana\" size=2><li><b>{$row['Subcategory']}</b></font><br><br> <ul>"; if ($row['udURL'] == ""){ echo "<font face=\"Verdana\">{$row['Bname']}</font>"; }else{ echo "<a href=\"http://{$row['udURL']}\"><font face=\"Verdana\">{$row['Bname']}</font></a>"; } echo "<br>"; if ($row['Slogan'] != '') { echo "<font face=\"Verdana\" size=2><i>{$row['Slogan']}</i></font><br>"; } if (($row['TFPhone'] != "") && ($row['LPhone'] != "")){echo "<font face=\"Verdana\" size=2>{$row['TFPhone']} / {$row['LPhone']}<br></font>"; }else{ echo "<font face=\"Verdana\" size=2>{$row['TFPhone']} {$row['LPhone']}<br></font>"; } if ($row['CLSmap'] == 'Y'){ echo "<font face=\"Verdana\" size=2><a href=\"maps/maps.php?IDENT={$row['ID']}\">Map/Directions</a></font>"; } echo"</li></ul> </li></ul> <script type=\"text/javascript\"> ddtreemenu.createTree(\"{$row['Subcategory']}\", false) </script>"; } echo " </td>"; $count++; // count one Subcategory } // end of while loop // if $count is not 0, finish any previous partial row/section of Subcategory data if($count != 0){ while($count % $columns != 0){ echo "<td> </td>"; $count++; } // close the row/section echo "</tr>\n</table>"; } echo "</table>\n"; // close overall table
  6. PFMaBiSmAd, thank you for your help! Your solution works perfectly. I don't think I would have worked it out from my previous code and especially not as elegantly. I now see what you meant by a counter. I've not done one of those before, so i see why it confused me. Great job! Thank you again for you time and patience.
  7. You said "You should only use the while() loop to fetch data from the result set and use a counter inside of the loop to determine when to start a new <tr>" I can see wht you're saying about the evaluation order. I'm a little confused about how to modify this code. Are you saying my WHILE loop should be inside the for loop? Isn't the FOR loop a counter? I appreciate your help!
  8. PFMaBiSmAd, I understand what you are saying about the order by, but it's not the order by that is the main problem, it's the fact that the first city in the array is not displaying whether I do an order by or not. I've tried it with & without order by. For example, without the for loop for the table columns, the output is DOT Boise, DOT Syracuse. With the for loop the output is DOT Syracuse DOT. No Boise and in a different order despite the fact that neither code has the order by clause.
  9. I'm getting strange output with the Cities section of this code. The first item in the array is not displaying, despite the fact that the other items and the <li> are. In fact, the <li> for the missing city is showing up last! :-\ Other than this one issue, the code works fine. I've been working on this since yesterday and am quite frustrated. I'm just not seeing why this is happening. Please, any help would be appreciated. ///////PROBLEM AREA MARKED BELOW, concerns a for loop//////// //State query $result = mysql_query("SELECT DISTINCT State FROM $DBTABLE WHERE Active='Y' ORDER BY State ASC"); while($row = mysql_fetch_array($result)) { //Echo out each State echo "<tr><td valign=\"top\" bgcolor=\"#FDD9BA\"> $row[state]</td></tr><tr><td>"; //City query $sub = mysql_query("SELECT City, CLSfolder FROM $DBTABLE WHERE Active='Y' AND State='{$row['State']}'"); while($subrow = mysql_fetch_array($sub)) { //Section to echo out each City. //set the number of columns and determine the number of rows $columns = 3; $num_rows = mysql_num_rows($sub); if ($num_rows != 0 ) { echo "<TABLE width=\"100%\" border=1 align=\"center\">\n"; ///////////PROBLEM AREA/////////////// //this for loop is so we can use the number of rows for($i = 0; $i < $num_rows; $i++) { $subrow = mysql_fetch_array($sub); if($i % $columns == 0) { //if there is no remainder, we want to start a new row echo "<TR>\n"; } echo "<td width=\"25%\" align=\"left\" valign=\"top\"><a href=\"http://www.domainname.com/$subrow[CLSfolder]\" target=\"_blank\"><font face=\"Verdana\" size=2><li>$subrow[City]</li></font></a><br></td>"; if(($i % $columns) == ($columns - 1) || ($i + 1) == $num_rows) { //if there is a remainder of 1, end the row //or if there is nothing left in our result set, end the row echo "</TR>\n"; } } ///////////END PROBLEM AREA/////////////// echo "<tr><td colspan=3> </td></tr></TABLE>"; } } } mysql_close($dbcnx);
  10. I've been working on this the past couple of hours and put in more data to get a clearer picture of the problem. What I've discovered is that I'm definately missing something here, but don't know what. The issue seems to be within the for loop, but the output is weird. It outputs all the right number of <li> dots, but one city within each state doesn't show up. I am unable to determine a rhyme or reason for the one city that doesn't show up. It's not alphabetical, it's not ID number... so I'm at a loss to explain this behavior. Would greatly appreciate any help.
  11. I'm integrating a dynamic columns script into my state/city script, but am having problems getting the cities to show. It's only displaying 1 city, the first alphabetically, when it should be showing 3. So that seems to indicate to me that the problem is the for loop not interating through the array. But this for loop works on my other pages where it is not within the while loops of the state/city script. So, either there is some conflict going on or something else I'm not seeing. An other pair of eyes looking at this would be wonderful. Thank you so much for your help! Output: State1 (should have a city showing) State2 (should have 2 cities showing) City1 //State query $result = mysql_query("SELECT DISTINCT State FROM $DBTABLE WHERE Active='Y' ORDER BY State ASC"); while($row = mysql_fetch_array($result)) { //Echo out each State echo "<tr><td valign=\"top\" bgcolor=\"#FDD9BA\"> $row[state]</td></tr><tr><td>"; //City query $sub = mysql_query("SELECT City, CLSfolder FROM $DBTABLE WHERE Active='Y' AND State='{$row['State']}'"); while($subrow = mysql_fetch_array($sub)) { //Section to echo out each City. //set the number of columns and determine the number of rows $columns = 3; $num_rows = mysql_num_rows($sub); if ($num_rows != 0 ) { echo "<TABLE width=\"100%\" border=1 align=\"center\">\n"; //this for loop is so we can use the number of rows for($i = 0; $i < $num_rows; $i++) { $subrow = mysql_fetch_array($sub); if($i % $columns == 0) { //if there is no remainder, we want to start a new row echo "<TR>\n"; } echo "<td width=\"25%\" align=\"left\" valign=\"top\"><a href=\"http://www.domainname.com/$subrow[CLSfolder]\" target=\"_blank\"><font face=\"Verdana\" size=2><li>$subrow[City]</li></a><br></td>"; if(($i % $columns) == ($columns - 1) || ($i + 1) == $num_rows) { //if there is a remainder of 1, end the row //or if there is nothing left in our result set, end the row echo "</TR>\n"; } } echo "<tr><td> </td></tr></TABLE>"; } } } echo "</td></tr></table>" ; mysql_close();
  12. Maq, Thank you, that works perfectly! Yeah, I did overlook the $DBTABLE needing double quotes. The associative array syntax with the curly braces is one I'm not as practiced with - thanks for the explanation.
  13. Hi, I'm using the solution I found here under the topic "[sOLVED] category's and subcategory's" For some reason, I'm not able to get the solution to work for me. What it does is only prints out the States, not the cities. No errors, just no cities despite the fact that tere are 2 state and 3 cities in the database. What I want is: State City A City B City C, Etc. Could a someone take a look at the code below and see if they can see why this isn't working. I appreciate the help!! <?php $result = mysql_query("SELECT DISTINCT State FROM $DBTABLE WHERE Active='Y' ORDER BY State ASC"); while($row = mysql_fetch_array($result)) { //Echo out each main echo ("$row[state]<br>"); $sub = mysql_query('SELECT City, CLSfolder FROM $DBTABLE WHERE (Active="Y") AND (State="' . $row['State'] . '"'); while($subrow = mysql_fetch_array($sub)) { //Echo out each sub. echo ("<br> Cities: $subrow[City] - $subrow[CLSfolder]"); } } mysql_close(); ?>
  14. 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; }
  15. 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; }
×
×
  • 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.