populate an array from mssql query
Posted: Tue Jul 28, 2009 9:45 am
Hi all, I am trying to add some data from a mssql query to an array variable called freeTrialCodes, the query is executing fine but I trying to figure how to populate the array with the data in result from query, the key value that I need is CONF_VALUE below is the code
This is what the query looks like in tables
please advise
conf_id domain_cd conf_key conf_value Conf_description
85 12 1648 1648 FREE_TRIAL_ORDER_CODE_IDS Order Code IDs for free trials.
86 12 1645 1645 FREE_TRIAL_ORDER_CODE_IDS Order Code IDs for free trials.
87 12 1433 1433 FREE_TRIAL_ORDER_CODE_IDS Order Code IDs for free trials.
88 12 1420 1420 FREE_TRIAL_ORDER_CODE_IDS Order Code IDs for free trials.
89 12 1405 1405 FREE_TRIAL_ORDER_CODE_IDS Order Code IDs for free trials.
90 12 1661 1661 FREE_TRIAL_ORDER_CODE_IDS Order Code IDs for free trials.
Code: Select all
$query = "SELECT * ";
$query .= "FROM OAG_SC_DOMAIN D ";
$query .= "JOIN OAG_SC_CONFIGURATION C ";
$query .= "ON D.DOMAIN_ID = C.DOMAIN_ID ";
$query .= "WHERE D.DOMAIN_ID = 12";
//execute the SQL query and return records
$result = mssql_query($query);
$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";
$s = mssql_fetch_array($result);
//display the results
while($row = mssql_fetch_array($result))
{
echo "result: " . $row["DOMAIN_CD"] . $row["CONF_VALUE"] . "\n";
}
//What I need to do here is populate the data from the resultset to an
// array called FreeTrialCodes
This is what the query looks like in tables
please advise
conf_id domain_cd conf_key conf_value Conf_description
85 12 1648 1648 FREE_TRIAL_ORDER_CODE_IDS Order Code IDs for free trials.
86 12 1645 1645 FREE_TRIAL_ORDER_CODE_IDS Order Code IDs for free trials.
87 12 1433 1433 FREE_TRIAL_ORDER_CODE_IDS Order Code IDs for free trials.
88 12 1420 1420 FREE_TRIAL_ORDER_CODE_IDS Order Code IDs for free trials.
89 12 1405 1405 FREE_TRIAL_ORDER_CODE_IDS Order Code IDs for free trials.
90 12 1661 1661 FREE_TRIAL_ORDER_CODE_IDS Order Code IDs for free trials.