PHP + MsSQL Checkbox sorunları =.

0 Cevap php

I have been working on this one topic for weeks. I'm creating a webpage that pulls information from MsSQL server. My problem is where there is a section with few check boxes. The checkboxes are suppose to be checked if they are found in the SQL database. If the borrower used money from "Savings", "Checking" and "Stock" those checkboxes should be checked in HTML page. In my case it is only checking whatever is on the first row of the SQL search list. So if the list has "Saving" on the first row, only the "Saving" checkbox will be checked not the rest on the list. I tried using loop (while($r->EOF)), but then it picks whatever is on the end of the list. Here is what I am using to pull data from the SQL server. Thank you in advance for your help. Really appreciate it!

function __construct($_ldid, $_lrid)

            $this->ldid = $_ldid;
            $this->lrid = $_lrid;

//$loan is defined in the PHP.class (which is shown below). 

$q = ("SELECT * FROM Tabel_name where loan_id = 885775")
$v = array($_ldid, $_lrid); 
$r = $db->Execute($q, $v); 
$this->downpaymenttype = $r->fields; //<- I think I have this line done wrong because it is suppose to store the outputs to an array. 

//So wherever the "$loan" is in HTML page, it will take the outputs from the above statement.

//The above code, which is in PHP.class file, outputs the following(or suppose to):
1    885775    Checking
2    885775    Saving
3    885775    Gift

HTML web sayfasında, aşağıdaki kodları çıktılara göre kutularını işaretlemek kontrol etmelisiniz:

<input type="checkbox" name="DPS1[]" id="DPS1-{$key}" {if $loan-> downpaymenttype.downpaymentsource == "Checking"} checked {/if}/> 

<input type="checkbox" name="DPS2[]" id="DPS2-{$key}" {if $loan-> downpaymenttype.downpaymentsource == "Saving"} checked {/if}/> 

<input type="checkbox" name="DPS3[]" id="DPS3-{$key}" {if $loan-> downpaymenttype.downpaymentsource == "Gift"} checked {/if}/> 

Ilk satırda biri çünkü sadece "kontrol" onay kutusunun işaretli oluyor.

Ben de döngü çalıştım, ama (ben oturumu için dizi nasıl kullanılacağını bilmiyorum sanırım) dizi depolamak değil

$q = ("SELECT Tabel_name FROM loan_downpaymentsource where loan_id = 885775"); 
$v = array($_ldid, $_lrid)); 
$r = $db->Execute($q, $v); 
while(!$r->EOF) { 
$this->downpaymenttype = $r->fields; 
$r->MoveNext(); 
} 

0 Cevap