creating a list from a query under a varriable
Posted: 26 Sep 2011, 17:41
Hi all,
Need your advice or assistance here, I have managed to work on a query in virtuemart "checkout thank you" that picks the autogenerated image ID from jos_phocagallery and then links it to the order id in the orders table, now my main issue is that I have been unable to get all these lists of purhased image_ids since I need them to be posted with the order detail... Whenever I put the
$image_id=db->f('title')
as illustrated in the code below, I only get one value even if the buyer buys two or more image_ids; However if I use the while statement like this;
$result = mysql_query($q) or die(mysql_error());
while($row = mysql_fetch_array($result)){;
//$image_id=$row;
echo "IMAGE NUMBER: ";
echo "<strong>";
echo $row['title'];
$image_id= $row['title'];
echo "</strong>";
echo "<br />";
}
All the listed raws are printed well, now is it possible that instead of printing the values, I transfer all the raws under title as a variable to the hidden filed like?
<input type="hidden" name="image_id" value="<?php echo $image_id; ?>" />
I know it might be a virtuemart question but I hope one has some insight coz it seems I am missing something...
Below is the sql I have created for the title field...
$q = "SELECT
title,
jos_phocagallery.vmproductid,
product_sku,
jos_vm_product.product_parent_id,
jos_vm_order_item.order_id,
jos_vm_order_item.product_id,
jos_vm_order_item.order_item_sku,
jos_vm_order_item.order_item_name,
jos_vm_product.product_id AS product_id1,
jos_vm_orders.order_id AS order_id1,
jos_vm_orders.order_number
FROM jos_phocagallery
INNER JOIN jos_vm_product ON jos_phocagallery.vmproductid = jos_vm_product.product_parent_id
INNER JOIN jos_vm_order_item ON jos_vm_product.product_id = jos_vm_order_item.product_id
INNER JOIN jos_vm_orders ON jos_vm_order_item.order_id = jos_vm_orders.order_id ";
//WHERE jos_vm_order_item.order_id ='.$order_id.'"
$q .=" WHERE jos_vm_order_item.order_id = '" . $order_id . "' GROUP BY title";
//$q .=" ORDER BY jos_vm_order_item.order_id";
$db->query($q);
$db->next_record();
$image=$db->f("title");
Need your advice or assistance here, I have managed to work on a query in virtuemart "checkout thank you" that picks the autogenerated image ID from jos_phocagallery and then links it to the order id in the orders table, now my main issue is that I have been unable to get all these lists of purhased image_ids since I need them to be posted with the order detail... Whenever I put the
$image_id=db->f('title')
as illustrated in the code below, I only get one value even if the buyer buys two or more image_ids; However if I use the while statement like this;
$result = mysql_query($q) or die(mysql_error());
while($row = mysql_fetch_array($result)){;
//$image_id=$row;
echo "IMAGE NUMBER: ";
echo "<strong>";
echo $row['title'];
$image_id= $row['title'];
echo "</strong>";
echo "<br />";
}
All the listed raws are printed well, now is it possible that instead of printing the values, I transfer all the raws under title as a variable to the hidden filed like?
<input type="hidden" name="image_id" value="<?php echo $image_id; ?>" />
I know it might be a virtuemart question but I hope one has some insight coz it seems I am missing something...
Below is the sql I have created for the title field...
$q = "SELECT
title,
jos_phocagallery.vmproductid,
product_sku,
jos_vm_product.product_parent_id,
jos_vm_order_item.order_id,
jos_vm_order_item.product_id,
jos_vm_order_item.order_item_sku,
jos_vm_order_item.order_item_name,
jos_vm_product.product_id AS product_id1,
jos_vm_orders.order_id AS order_id1,
jos_vm_orders.order_number
FROM jos_phocagallery
INNER JOIN jos_vm_product ON jos_phocagallery.vmproductid = jos_vm_product.product_parent_id
INNER JOIN jos_vm_order_item ON jos_vm_product.product_id = jos_vm_order_item.product_id
INNER JOIN jos_vm_orders ON jos_vm_order_item.order_id = jos_vm_orders.order_id ";
//WHERE jos_vm_order_item.order_id ='.$order_id.'"
$q .=" WHERE jos_vm_order_item.order_id = '" . $order_id . "' GROUP BY title";
//$q .=" ORDER BY jos_vm_order_item.order_id";
$db->query($q);
$db->next_record();
$image=$db->f("title");