Welcome Guest, Not a member yet? Register   Sign In
Retrieving information from arrays
#2

[eluser]Michael Wales[/eluser]
I would store my information a bit differently. Rather than making a variable amount of 'Image' or 'Name' arrays, I would make a variable amount of arrays, each with a 'Name' or 'Image' key - for example:

Code:
$data[$i]['Image'] = $resultrow2[$i] ->Image; // {../Images/test.jpg, ../Images/test2.jpg, ../Images/test.jpg)
$data[$i]['Name'] = $resultrow3[$i] ->productName; //{"one", "two", "three"]
$data[$i]['Price'] = $resultrow4[$i] ->Price; // {10,20,30)
$data[$i]['Desc'] = $resultrow5[$i] ->Description; // {"first one, second, third"}

Then in your view:
Code:
<? foreach ($i as $product) {
  echo '<img src="' . $product['Image'] . '" />';
  echo $product['Name'] . 'costs $' . $product['Price'];
  echo '<br />' . $product['Desc'];
?&gt;


Messages In This Thread
Retrieving information from arrays - by El Forum - 10-21-2007, 12:56 PM
Retrieving information from arrays - by El Forum - 10-21-2007, 02:46 PM



Theme © iAndrew 2016 - Forum software by © MyBB