Lassie Posted January 9, 2007 Share Posted January 9, 2007 Mant thanks to those who have helped with this problem before. I have moved on but am still in trouble.I am trying to build a download link for customers to pick_up their purchases.The logic is:1. pass the cart variables and the product id to a function which retrieves thedownload file reference from the database.2.make an array of the results which is returned to a function which will store them in a variable.This will be used to copy the file to a pick up folder.I am printing the links to establish that I have this part working correctly.The problem is my array is only capturing the last prouct selection.The code is://Call the function to retirieve the download link from the database.$dl_link=display_dl_link2($_SESSION['cart'],'product_id');//function display_dl_link2function display_dl_link2($cart,$product_id){foreach ($cart as $product_id => $qty) { echo "The value of $product_id is $qty<br />";//print products as debug check. All selected products show. }// capture the product ids if (!$product_id || $product_id=='') { return false; } $connection = db_connect(); $query = "select dl_link from products where product_id='$product_id'"; $result = mysql_query($query); if (!$result) { mysql_error(); return false; } if(mysql_num_rows($result)==0) { echo "there were no results"; }else { $result = db_result_to_array($result);//array shows only the last product selection return $result; { } }}This is the debug result I getThe value of 6 is 1The value of 13 is 1Array( [0] => Array ( [dl_link] => the download link ))Any help appreciated.Note to EditiorYou have previously asked me to enclose my code in code tags.Could you give me an example please.lassie Link to comment https://forums.phpfreaks.com/topic/33454-continuing-aray-problem/ Share on other sites More sharing options...
Barand Posted January 9, 2007 Share Posted January 9, 2007 [nobbc][code]<?php echo 'Hello World';?>[/code][/nobbc]You can type the code tags yourself or select the code then click the "insert code" icon above the reply box. Link to comment https://forums.phpfreaks.com/topic/33454-continuing-aray-problem/#findComment-156593 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.