WendyM Posted October 26, 2003 Share Posted October 26, 2003 In links manager, I'd like to show how many links are in each category. I have the links.php from a site which does this....but cannot seem to extract the needed info. So far, I've made a complete mess and broke the contrib a couple different times. :o lol (it's back together, of course, cuz I copied my original "links.php") I'm not much of a programmer, in any language. But I'm sure trying to learn 'em. Thanks in advance! Wendy :P Quote Link to comment Share on other sites More sharing options...
VJ Posted October 27, 2003 Share Posted October 27, 2003 I have the links.php from a site which does this....but cannot seem to extract the needed info. So far, I've made a complete mess and broke the contrib a couple different times. lol (it's back together, of course, cuz I copied my original "links.php") Oops, here you go... In your (original) links.php, replace the following (around line 90) - if ($number_of_categories > 0) { $rows = 0; while ($categories = tep_db_fetch_array($categories_query)) { $rows++; $lPath_new = 'lPath=' . $categories['link_categories_id']; $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%'; echo ' <td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_LINKS, $lPath_new) . '">'; if (tep_not_null($categories['link_categories_image'])) { echo tep_links_image(DIR_WS_IMAGES . $categories['link_categories_image'], $categories['link_categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br>'; } else { echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', $categories['link_categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT, 'style="border: 3px double black"') . '<br>'; } echo '<br><b><u>' . $categories['link_categories_name'] . '</b></u></a><br><br>' . $categories['link_categories_description'] . '</td>' . "\n"; if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) { echo ' </tr>' . "\n"; echo ' <tr>' . "\n"; } } } else { with, if ($number_of_categories > 0) { $rows = 0; while ($categories = tep_db_fetch_array($categories_query)) { $rows++; $lPath_new = 'lPath=' . $categories['link_categories_id']; $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%'; $categories_count_query = tep_db_query("select links_id from " . TABLE_LINKS_TO_LINK_CATEGORIES . " where link_categories_id = '" . (int)$categories['link_categories_id'] . "'"); $number_of_links = tep_db_num_rows($categories_count_query); echo ' <td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_LINKS, $lPath_new) . '">'; if (tep_not_null($categories['link_categories_image'])) { echo tep_links_image(DIR_WS_IMAGES . $categories['link_categories_image'], $categories['link_categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br>'; } else { echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', $categories['link_categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT, 'style="border: 3px double black"') . '<br>'; } echo '<br><b><u>' . $categories['link_categories_name'] . '</b></u></a> (' . $number_of_links . ')'; echo '<br><br>' . $categories['link_categories_description'] . '</td>' . "\n"; if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) { echo ' </tr>' . "\n"; echo ' <tr>' . "\n"; } } } else { Good luck! :) VJ Quote Link to comment Share on other sites More sharing options...
WendyM Posted October 27, 2003 Author Share Posted October 27, 2003 works on the links categories page, but when I click on a category, it gives me a syntax error: 1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'select ld.links_title, ld.links_description, l.links_url, l.lin select count(l.links_id) as total select ld.links_title, ld.links_description, l.links_url, l.links_clicked, l.links_id from links_description ld, links l, links_to_link_categories l2lc where l.links_status = '2' and l.links_id = l2lc.links_id and ld.links_id = l2lc.links_id and ld.language_id = '1' and l2lc.link_categories_id = '4' [TEP STOP] Thank you so much for helping me with this. I appreciate it very very much. :D Wendy Quote Link to comment Share on other sites More sharing options...
VJ Posted October 27, 2003 Share Posted October 27, 2003 I'm afraid I wasn't able to locate the code resembling your error snippet, in the original links.php file. Have you made any changes in the SQL queries? select count(l.links_id) as total select ld.links_title, ld.links_description, l.links_url, l.links_clicked, l.links_id from links_description ld, links l, links_to_link_categories l2lc where l.links_status = '2' and l.links_id = l2lc.links_id and ld.links_id = l2lc.links_id and ld.language_id = '1' and l2lc.link_categories_id = '4' Anyways, there's a mistake in the above query (obviously!). You might need to remove this section (right at the beginning), select count(l.links_id) as total HTH, VJ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.