a multi dimensional array needed?
Posted: Wed Apr 19, 2006 10:37 pm
Hi all,
I've just about given up trying to understand these arrays. I've searched and read tutorials and am getting headaches
If anyone has some advice I basically have this:
Now, does that work? Assuming there are 3000 products in the database table \, will they all be stuck into that array? And if so, how can I get them out? It appears using this kind of code (below) I can only extract the id and the type_id. But I suspect I'm not understanding fully.
How can I also access the price part of that array?
Any help REALLY appreciated...
Rob
I've just about given up trying to understand these arrays. I've searched and read tutorials and am getting headaches
If anyone has some advice I basically have this:
Code: Select all
//get the transactions that are of type 'stock' and that are within the date range and stick them in an array
//===========================================================================
mysql_select_db($dbname);
$sql = "SELECT * FROM transactions WHERE type = 'stock' && date <= '$end_date' && date >= '$start_date' ORDER BY id ASC";
$content = mysql_query($sql);
$Xcontent = mysql_fetch_array($content);
$ShowMax = mysql_num_rows($content);
for ($y=1; $y<=$ShowMax; $y++)
{
//Get the info from the database and smack it in variables for user later
$transaction_id = $Xcontent["id"];
$transaction_type_id = $Xcontent["type_id"];
$transaction_price = $Xcontent["price"];
//now stick this stuff into an array
$trans_multi_array = array("$transaction_id", "$transaction_type_id", "$transaction_price");
$Xcontent = mysql_fetch_array($content);
}Code: Select all
foreach($trans_multi_array as $transaction_id => $transaction_type_id) {}How can I also access the price part of that array?
Any help REALLY appreciated...
Rob