Nieuw lid |
|
beste
Op men formulier, dat ik met json wil vullen, heb ik een combobox.
nu wil ik deze vullen en ik dacht dit met een while lus te doen,maar blijkbaar geeft dit fouten...
$id = $_REQUEST['id'];
$sql = "SELECT * FROM timeRegistration_project WHERE projectID = %d";
$result = db_query($sql,$id);
$obj = db_fetch_object($result);
$sql2 = "SELECT * FROM timeRegistration_relation";
$result2 = db_query($sql2);
print '{
success: true,
data: {
"textboxProjectID" : "' . $obj->projectID . '",
"textboxProjectCode" : "' . $obj->projectCode . '",
"textboxProjectDescription" : "' . $obj->projectDescription . '",
"textboxInternProject" : "' . $obj->internProject . '",
"textboxProjectTypeID" : "' . $obj->projectTypeID . '",
"textboxProjectInfo" : "' . $obj->projectInfo . '",
"textboxProjectPrice" : "' . $obj->projectPrice . '",
"textboxMovementID" : "' . $obj->movementID . '",
"textboxMovementCost" : "' . $obj->movementCost . '",
"textboxInvoiceTypeID" : "' . $obj->invoiceTypeID . '",
"textboxStateID" : "' . $obj->stateID . '",
"textboxStartDate" : "' . $obj->startDate . '",
"textboxExpectedEndDate" : "' . $obj->expectedEndDate . '",
"textboxRelationID" : "' . $obj2->name . '",
' . while($obj2 = db_fetch_object($result2)){. '"textboxRelationID" : "' . $obj2->name . '"' .}.'
}
}';
$id = $_REQUEST['id']; $sql = "SELECT * FROM timeRegistration_project WHERE projectID = %d"; $result = db_query($sql,$id); $obj = db_fetch_object($result); $sql2 = "SELECT * FROM timeRegistration_relation"; $result2 = db_query($sql2); success: true, data: { "textboxProjectID" : "' . $obj->projectID . '", "textboxProjectCode" : "' . $obj->projectCode . '", "textboxProjectDescription" : "' . $obj->projectDescription . '", "textboxInternProject" : "' . $obj->internProject . '", "textboxProjectTypeID" : "' . $obj->projectTypeID . '", "textboxProjectInfo" : "' . $obj->projectInfo . '", "textboxProjectPrice" : "' . $obj->projectPrice . '", "textboxMovementID" : "' . $obj->movementID . '", "textboxMovementCost" : "' . $obj->movementCost . '", "textboxInvoiceTypeID" : "' . $obj->invoiceTypeID . '", "textboxStateID" : "' . $obj->stateID . '", "textboxStartDate" : "' . $obj->startDate . '", "textboxExpectedEndDate" : "' . $obj->expectedEndDate . '", "textboxRelationID" : "' . $obj2->name . '", ' . while($obj2 = db_fetch_object($result2)){. '"textboxRelationID" : "' . $obj2->name . '"' .}.' } }';
de eerste sql-query leest de gegevens uit tabel projecten, hierdoor krijg ik de geselecteerde relationID(benaderbaar met $obj->id)
de tweede query haalt alle relaties op
' . while($obj2 = db_fetch_object($result2) {. '"textboxRelationID" : "' . $obj2->name . '"' .}.'
' . while($obj2 = db_fetch_object($result2) {. '"textboxRelationID" : "' . $obj2->name . '"' .}.'
hiermee probeer ik de naam dan uittelezen...
1 mijn vraag is dus, mag een while lus?
1.1 indien ja,wat doe ik verkeerd?
1.2 indien nee,hoe los ik dit dan op?
2 hoe kan ik de id als value meegeven?
groetjes steven
|