Code: Select all
//get the transactions that are of type 'service' and stick them in an array
//===========================================================================
mysql_select_db($dbname);
$sql = "SELECT * FROM transactions WHERE type = 'services' 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_type_id = $Xcontent["type_id"]; //get the service name
$transaction_price = $Xcontent["price"]; //get the service price
//stick the transaction id and price into an array
$transaction_name_array["$transaction_type_id"] = $transaction_price;
$Xcontent = mysql_fetch_array($content);
}
foreach($transaction_name_array as $type_id => $price)
{
$temp_counter++;
echo "<br>($temp_counter)type_id: $type_id, price: $price";
}The problem:
The array, when displaying it with the foreach loop at the bottom, only shows 28 transactions!!!! erm... why? I do have code above this that sticks data into another array (that puts exactly 28 transactions into that other array) but even when i completely REMOVE that earlier code, I still get it. Is it a memory problem? do i need to flush the variables or something strange like that?
I will provide the full code for the page here, for those that are interested in seeing it in its whole:
Thanks, any advice apprecaited,
Rob
Code: Select all
//set up counters and misc vars
$temp_counter = "0";
//connect to database
$connection = mysql_connect($dbhost, $dbusername, $dbpassword);
//get the service names database and stick it in an array
//========================================================
mysql_select_db($dbname);
$sql = "SELECT * FROM services ORDER BY id ASC";
$content = mysql_query($sql);
$Xcontent = mysql_fetch_array($content);
$cShowMax = mysql_num_rows($content);
for ($y=1; $y<=$cShowMax; $y++)
{
//Get the info from the database and smack it in variables for user later
$service_name = $Xcontent["name"]; //get the service name
$service_id = $Xcontent["id"]; //get the service name
//stick the service name into an array
$service_name_array["$service_name"] = $service_name;
$service_id_array["$service_id"] = $service_id;
$Xcontent = mysql_fetch_array($content);
}
//get the transactions that are of type 'service' and stick them in an array
//===========================================================================
mysql_select_db($dbname);
$sql = "SELECT * FROM transactions WHERE type = 'services' 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_type_id = $Xcontent["type_id"]; //get the service name
$transaction_price = $Xcontent["price"];
//stick the transaction id into an array
$transaction_name_array["$transaction_type_id"] = $transaction_price;
$Xcontent = mysql_fetch_array($content);
}
foreach($transaction_name_array as $type_id => $price)
{
$temp_counter++;
echo "<br>($temp_counter)type_id: $type_id, price: $price";
}