tinytim Posted August 11, 2006 Share Posted August 11, 2006 Can anyone give me an idea of how to call up a download link for a product from the product_info.php page. I have very little experience with mysql commands. The code below gives me a list of all the files in the download folder. How do I adapt this to give only the right file, and a link to it? <?php $products_downloads_name_query = tep_db_query("select distinct patdo.products_attributes_id, patdo.products_attributes_filename from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " patdo, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.products_attributes_id = patdo.products_attributes_id = '" . (int)$products_attributes_id . "' order by patdo.products_attributes_filename"); while ($products_attributes_filename = tep_db_fetch_array($products_downloads_name_query)) { ?> <tr> <td class="main"><?php echo $products_attributes_filename['products_attributes_filename'] . ':'; ?></td> </tr> Link to comment Share on other sites More sharing options...
matrix2223 Posted August 11, 2006 Share Posted August 11, 2006 if you are adding this in the product discription and if doesnt really matter who downloads it you can use this: <br> <a href="/your_path.php">Some text here</a> Link to comment Share on other sites More sharing options...
tinytim Posted August 11, 2006 Author Share Posted August 11, 2006 if you are adding this in the product discription and if doesnt really matter who downloads it you can use this: <br> <a href="/your_path.php">Some text here</a> Thats not a very pretty way to do it. I am trying to pull the links from the product_attributes_download table. Link to comment Share on other sites More sharing options...
tinytim Posted August 11, 2006 Author Share Posted August 11, 2006 I have figured it out. If you want to add a download link to the product info page, just insert this code: <?php $product_filename_query = tep_db_query("select pad.products_attributes_filename from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.products_attributes_id = pad.products_attributes_id "); $product_filename = tep_db_fetch_array($product_filename_query); $products_attributes_filename = $product_filename['products_attributes_filename'] ?> <p><?php echo "<a href= \"download/$products_attributes_filename\"><b>Download</b></a>"; ?></p> Somewhere in the product_info.php file. I put it right after <?php $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'"); $products_attributes = tep_db_fetch_array($products_attributes_query); if ($products_attributes['total'] > 0) { ?> This is great if you want to give members free downloads to your products. I am using this along with a subscription script you can find in the contributions section. Link to comment Share on other sites More sharing options...
Guest Posted August 11, 2006 Share Posted August 11, 2006 change the query $products_downloads_name_query = tep_db_query("select distinct patdo.products_attributes_id, patdo.products_attributes_filename from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " patdo, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.products_attributes_id = patdo.products_attributes_id = '" . (int)$products_attributes_id . "' order by patdo.products_attributes_filename"); to $products_downloads_name_query = tep_db_query("select distinct patdo.products_attributes_id, patdo.products_attributes_filename from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " patdo, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.products_attributes_id = patdo.products_attributes_id order by patdo.products_attributes_filename"); and try it. PS: was a bit late... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.