Example #1
0
function options_for_select($table, $id_field, $value_field, $blank)
{
    global $dbConn, $dbResult;
    $sql = "select " . $id_field . ", " . $value_field . " from " . $table . " ORDER BY " . $value_field;
    $dbResult = odbc_exec($dbConn, $sql);
    $options = "";
    if ($blank) {
        $options .= "<option value=''>-n/a-</option>\n";
    }
    while (next_row()) {
        $options .= '<option value="' . get_column_value($id_field) . '">';
        $options .= get_column_value($value_field);
        $options .= "</option>\n";
    }
    return $options;
}
d($srch_args);
d(str_replace("<ENDDATE>", $end_Listing_Date, str_replace("<STARTDATE>", $start_Listing_Date, $sql_totals . $where)) . "<BR><BR>");
$rs_totals = query(str_replace("<ENDDATE>", $end_Listing_Date, str_replace("<STARTDATE>", $start_Listing_Date, $sql_totals . $where)), $conn1);
$row_totals = next_row($rs_totals);
// echo $row_totals['Pop_no_Listings_CY']."<BR>";
// echo $row_totals['Pop_no_Listings_PY']."<BR><BR>";
// echo $row_totals['Pop_Listing_Vol_CY']."<BR>";
// echo $row_totals['Pop_Listing_Vol_PY']."<BR>";
// echo str_replace("<Pop_Listing_Vol_CY>",$row_totals['Pop_Listing_Vol_CY'],str_replace("<Pop_Listing_Vol_PY>",$row_totals['Pop_Listing_Vol_PY'],str_replace("<Pop_no_Listings_PY>",$row_totals['Pop_no_Listings_PY'],str_replace("<Pop_no_Listings_CY>",$row_totals['Pop_no_Listings_CY'],str_replace("<ENDDATE>",$end_Listing_Date,str_replace("<STARTDATE>",$start_Listing_Date,$sql.$where.$grouping.$sort))))))."<BR><BR>";
//$rs = query (str_replace("<ENDDATE>",$end_Listing_Date,str_replace("<STARTDATE>",$start_Listing_Date,$sql.$where.$grouping.$sort)), $conn1);
//$rs = query (str_replace("<Pop_no_Listings_PY>",$row_totals['Pop_no_Listings_PY'],str_replace("<Pop_no_Listings_CY>",$row_totals['Pop_no_Listings_CY'],str_replace("<ENDDATE>",$end_Listing_Date,str_replace("<STARTDATE>",$start_Listing_Date,$sql.$where.$grouping.$sort)))), $conn1);
d(str_replace("<Pop_Listing_Vol_CY>", $row_totals['Pop_Listing_Vol_CY'], str_replace("<Pop_Listing_Vol_PY>", $row_totals['Pop_Listing_Vol_PY'], str_replace("<Pop_no_Listings_PY>", $row_totals['Pop_no_Listings_PY'], str_replace("<Pop_no_Listings_CY>", $row_totals['Pop_no_Listings_CY'], str_replace("<ENDDATE>", $end_Listing_Date, str_replace("<STARTDATE>", $start_Listing_Date, $sql . $where . $grouping . $sort)))))));
$rs = query(str_replace("<Pop_Listing_Vol_CY>", $row_totals['Pop_Listing_Vol_CY'], str_replace("<Pop_Listing_Vol_PY>", $row_totals['Pop_Listing_Vol_PY'], str_replace("<Pop_no_Listings_PY>", $row_totals['Pop_no_Listings_PY'], str_replace("<Pop_no_Listings_CY>", $row_totals['Pop_no_Listings_CY'], str_replace("<ENDDATE>", $end_Listing_Date, str_replace("<STARTDATE>", $start_Listing_Date, $sql . $where . $grouping . $sort)))))), $conn1);
$iRowCount = 0;
//sr 11/18/04    while ($row = next_row ($rs) AND $iRowCount < 250) {
while ($row = next_row($rs) and $iRowCount < $maxrecords) {
    // accumulate data for top 10
    if ($iRowCount <= 9) {
        if ($order_by == "LIST_UNITS_CY") {
            $xLabels = $xLabels . "&xLabels[]=" . urlencode($row['grp_Name']);
            $data1 = $data1 . "&data1[]=" . $row['no_Listings_CY'];
            $data2 = $data2 . "&data2[]=" . $row['no_Listings_PY'];
            $ytitle = "List Units";
            $data2label = "Previous Yr";
            $charttitle = "Sorted by List Units Current Year";
        } else {
            if ($order_by == "MKT_SHARE_CY") {
                $xLabels = $xLabels . "&xLabels[]=" . urlencode($row['grp_Name']);
                $data1 = $data1 . "&data1[]=" . $row['PctTot_Listings_CY'] * 100;
                $data2 = $data2 . "&data2[]=" . $row['PctTot_Listings_PY'] * 100;
                $ytitle = "Market Share";
$plot->SetPlotType('lines');
$plot->SetFileFormat('jpg');
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
$plot->SetXDataLabelPos('none');
# Don't draw the initial, empty values:
$plot->SetDrawBrokenLines(True);
# Force the Y range, or it will use the first frame to calculate:
$plot->SetPlotAreaWorld(NULL, $min_y, NULL, $max_y);
$plot->SetPrintImage(False);
# Main loop:
$plot->StartStream();
$timestamp = microtime(TRUE);
for ($frame = 0; $run_forever || $frame < $n_frames; $frame++) {
    # Set PHP timeout so it won't terminate the script early.
    set_time_limit(60);
    # Discard the oldest data row, and shift in the new row:
    array_shift($data);
    $data[] = next_row($frame);
    # Set a plot title that includes the frame number:
    $plot->SetTitle(sprintf("Moving Plot Test (Frame %4d)", $frame));
    # Reload the data array:
    $plot->SetDataValues($data);
    # Draw and output the plot:
    $plot->DrawGraph();
    $plot->PrintImageFrame();
    # Sleep until it is time to start the next frame:
    time_sleep_until($timestamp += $frame_time);
}
# End the stream:
$plot->EndStream();