Wednesday, March 23, 2011

Access database in php

<?php
error_reporting(-1);

$man_db = db_query("SELECT DISTINCT manufacture_name FROM {drup_deductible} WHERE drup_deductible.carrier_name LIKE '%Verizon%' ORDER BY manufacture_name");
$model_db = db_query("SELECT DISTINCT model_name FROM {drup_deductible} WHERE manufacture_name LIKE '%".$_REQUEST['manufacturer']."%' ORDER BY model_name");
$deduct_db = db_query("SELECT drup_deductible.tier_name, drup_tier.tier_name, drup_tier.tier_amount, drup_tier.tier_premium FROM {drup_tier},{drup_deductible} WHERE drup_tier.tier_name = drup_deductible.tier_name AND drup_deductible.carrier_name = 'Verizon' LIMIT 1");

$today = date('m/d/Y');
if($today >= "06/01/2011"){
    $effectiveDate = "05/17/2009";
} else {
    $effectiveDate = "02/01/11";
}

function dropdownfunc($name, $rowname, $source){
    foreach($source as $row) {
        if ($row->$rowname == $_REQUEST[$name])
        {
            $s = " SELECTED";
        } else {
            $s = "";
        }
        echo '<option value="'.$row->$rowname.'"'. $s.'>'.$row->$rowname.'</option>';
    }
}
?>
<div id="newwrapper">
    <div style="margin-top: -23px; margin-left: -22px; /margin-left: -15px; width: 975px; position: relative;">
        <div style="float:left; width:648px; margin-right: 5px;">
            <div id="vz-redesign-top"></div>
            <div style="padding-left: 25px; margin-top: 20px; /margin-top: 0px; position: relative; min-height: 200px;">
                <p style="font-size: 16px;">Select your manufacturer and model</p>
                <form method="POST" action="lookup">
                    <div style="float:left;width:160px;padding-right:15px; margin-top: 0px;">
                        <span style="font-size: 16px !important;">Manufacturer</span><br/>
                        <select name="manufacturer" onchange="this.form.submit();">
                            <option value="">Select a manufacturer</option>
                            <?php dropdownfunc('manufacturer', 'manufacture_name', $man_db); ?>
                        </select>
                    </div>
                    <input type="hidden" name="_submit" value="1">
                    <div style="float:left;width:150px;">
                        <span style="font-size:16px !important; margin-bottom: 10px;">Model</span><br/>
                        <select name="model" onchange="this.form.submit();"><br/>
                            <option value="">Select a model</option>
                            <?php dropdownfunc('model', 'model_name', $model_db); ?>
                        </select>
                    </div>
               </form>

               </form>
               </div>
               </div>
               </div>
               </div>

No comments:

Post a Comment