Rachael w. Posted February 17, 2008 Posted February 17, 2008 I am having trouble getting some code to work and I was hoping someone out there could tell me what I am doing wrong: I would like the manufacturer to show on the product info page, but be clickable (a link). Here's the code I've used to get it to show (and this works fine): <?php $manufacturer_query = tep_db_query("select m.manufacturers_name from " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS . " p where p.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and p.manufacturers_id = m.manufacturers_id"); $manufacturer = tep_db_fetch_array($manufacturer_query); ?> <tr> <td align="left" class=main><?php if (tep_not_null($manufacturer['manufacturers_name'])) {echo TEXT_MANUFACTURERS, $manufacturer['manufacturers_name'];}?></td> </tr> However, when I change that last bit to the code below to have the link it doesnt seem to work, I just cant see why (perhaps I've stared at it too long). It doesnt return an error, just doesnt show up. <tr> <td align="left" class=main><?php if (tep_not_null($manufacturer['manufacturers_name'])) {echo TEXT_MANUFACTURERS, '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $manufacturers['manufacturers_id'] , 'NONSSL') . '">'. $manufacturers['manufacturers_name'];}?></td> </tr> Thanks for looking at it for me.
germ Posted February 17, 2008 Posted February 17, 2008 Without actually seeing what ends up in the HTML source, the only thing I see missing is the "end of anchor" tag. Change this: </td> to: </a></td> If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
Rachael w. Posted February 17, 2008 Author Posted February 17, 2008 Thanks for the reply! Duh, missed that. I've added it but it is still not showing the manufacturers name. It looks like the link is working in the source, but of course there is nothing showing up to click on. I think I have something out of order, but I seem to have gone blind to it. Here's the source <tr> <td align="left" class="main" ><b>Manufacturer: </b><a href="http://www.xxxxx.com/index.php?manufacturers_id="></a></td> </tr>
germ Posted February 17, 2008 Posted February 17, 2008 tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $manufacturers['manufacturers_id'] , 'NONSSL') Remove the s in that piece of the code. If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
Rachael w. Posted February 17, 2008 Author Posted February 17, 2008 :huh: ARRRGGH! I figured it out, it was an "s" where there shouldnt have been one! The code should be: <td align="left" class=main ><?php if (tep_not_null($manufacturer['manufacturers_name'])) {echo TEXT_MANUFACTURERS, '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $manufacturers['manufacturers_id'] , 'NONSSL') . '">'. $manufacturer['manufacturers_name'] . '</a>';}?></td> Its on the end there. I had $manufacturers['manufacturers_name'], took off the s on $manufacturers and its working. Thanks for holding my hand there!
germ Posted February 17, 2008 Posted February 17, 2008 GMTA! :thumbsup: :lol: If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
Rachael w. Posted February 17, 2008 Author Posted February 17, 2008 Now to figure out where I went wrong with the link! It just goes to a blank manufacturer page, I'll have to tweak it to get it to find the actual manufacturer... I'm open to suggestions :)
germ Posted February 17, 2008 Posted February 17, 2008 You seem to be an above average, resourceful, intelligent young lady, have you looked at the code in the osC file manufacturer_info.php? :unsure: If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
Rachael w. Posted February 17, 2008 Author Posted February 17, 2008 Ahh Haaah! Its working! Here's the working code, just in case anyone out there would like to show the manufacturer in the product info page and have it be clickable to that manufacturers products page. Of course you'll need to put it where you want it and tweak it for your site. <?php $manufacturer_query = tep_db_query("select m.manufacturers_name, m.manufacturers_id from " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS . " p where p.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and p.manufacturers_id = m.manufacturers_id"); $manufacturer = tep_db_fetch_array($manufacturer_query); ?> <tr> <td align="left" class=main ><?php if (tep_not_null($manufacturer['manufacturers_name'])) {echo TEXT_MANUFACTURERS, '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $manufacturer['manufacturers_id'] , 'NONSSL') . '">'. $manufacturer['manufacturers_name'] . '</a>';}?></td> </tr> Notice I have the TEXT_MANUFACTURERS in there. That will require you to add it to your language files with what you'd like it to show (ie it could say: Manufacturer:, Designer:, Guy who made this: and so on) Also, see that tep_not_null in there? That is so that nothing shows if you do not have a manufacturer associated with your product. I didnt want to have Manufacturer: (blank) when I didnt have that info added.
germ Posted February 17, 2008 Posted February 17, 2008 You seem to be an above average, resourceful, intelligent young lady And you proved me right! ;) If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
Rachael w. Posted February 17, 2008 Author Posted February 17, 2008 :blush: Why thank you Jim! At least some out there will get to see the aggravating process of coming up with workable code! I thought I'd add this here too. If anyone is using the manufacturers2 contrib I sent in a while back and would like to add more manufacturers heres the code, just keep substituting the number for as many manufacturers as you have. (I have 6 so I would substitute 3 for the 2, and so on) <?php $manufacturer2_query = tep_db_query("select m2.manufacturers2_name, m2.manufacturers2_id from " . TABLE_MANUFACTURERS2 . " m2, " . TABLE_PRODUCTS . " p where p.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and p.manufacturers2_id = m2.manufacturers2_id"); $manufacturer2 = tep_db_fetch_array($manufacturer2_query); ?> <tr> <td align="left" class=main ><?php if (tep_not_null($manufacturer2['manufacturers2_name'])) {echo TEXT_MANUFACTURERS2, '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers2_id=' . $manufacturer2['manufacturers2_id'] , 'NONSSL') . '">'. $manufacturer2['manufacturers2_name'] . '</a>';}?></td> </tr>
Recommended Posts
Archived
This topic is now archived and is closed to further replies.