Log in
BSU INFO-TECH
FB COMMENT
add rows to table dynamically and save 2 d database
2 posters
Page 1 of 1
mye- Staff Sergeant
-
Number of posts : 113
Age : 36
Location : La Trinidad
Job/hobbies : Computer Instructor
Reputation : 0
Registration date : 2008-11-27
mye- Staff Sergeant
-
Number of posts : 113
Age : 36
Location : La Trinidad
Job/hobbies : Computer Instructor
Reputation : 0
Registration date : 2008-11-27
Re: add rows to table dynamically and save 2 d database
hi guys..i just ned help po sana d2. n d above images u can see dat initially d table has only one row.now f d user wants 2 add more rows, he/she will just click d add row button then madadagdagan ng isang vacant rows ung rows. mapapansin nu din na sa column6 my 3 checkboxes w/ 3 options wherein d user can select 1 or more from d options given.ang problema q po d2 pg clinik ng user ung submit button suposedly ang laman ng database eh eto:
Record1:
name: Max Gonzales
age: 22
gender:Male
position_applied:Accountant I
qualified:ffi
not_qualified:LE,LS
Record2:
name: Lanie Guiterez
age: 25
gender: Female
position_applied: Clerk I
qualified:ffi
not_qualified:EA
pero ang nangyayari ang laman ng field na not_qualified both in record1 and 2 eh LE,LS,EA..
kinuha nya lahat ng chineck ng user sa checkbox taz un ang isa2ve nya sa lahat ng records under not_qualified..any help po please..tnx
Record1:
name: Max Gonzales
age: 22
gender:Male
position_applied:Accountant I
qualified:ffi
not_qualified:LE,LS
Record2:
name: Lanie Guiterez
age: 25
gender: Female
position_applied: Clerk I
qualified:ffi
not_qualified:EA
pero ang nangyayari ang laman ng field na not_qualified both in record1 and 2 eh LE,LS,EA..
kinuha nya lahat ng chineck ng user sa checkbox taz un ang isa2ve nya sa lahat ng records under not_qualified..any help po please..tnx
mye- Staff Sergeant
-
Number of posts : 113
Age : 36
Location : La Trinidad
Job/hobbies : Computer Instructor
Reputation : 0
Registration date : 2008-11-27
Re: add rows to table dynamically and save 2 d database
ngek sri d nya pala nacontain lahat nung image kaya ung pang 6th na column na cnasabi q eh eto..
mye- Staff Sergeant
-
Number of posts : 113
Age : 36
Location : La Trinidad
Job/hobbies : Computer Instructor
Reputation : 0
Registration date : 2008-11-27
Re: add rows to table dynamically and save 2 d database
Layout mo po ng DB?
yong not qualified ba iisang field lang xa??? or one field per LA, LE and LS???
kasi pwede ganito
assuming that checkboxes names are LA, LE and LS
$not_Qualified = "";
if (LA.value == true)
$not_Qualified += "LA";
if (LE.value == true)
$not_Qualified += " LE";
if (LS.value == true)
$not_Qualified += " LS;
// tas
$query = "INSERT INTO tbl_churva(.....,not_qualified) values (......," + $not_Qualified + ");";
// yan na query string... assuming yan na ang column name sa table mo for not qualified is "not_qualified".
// ung mga ...., yan ung mga ibang field na sinisave mo......
yong not qualified ba iisang field lang xa??? or one field per LA, LE and LS???
kasi pwede ganito
assuming that checkboxes names are LA, LE and LS
$not_Qualified = "";
if (LA.value == true)
$not_Qualified += "LA";
if (LE.value == true)
$not_Qualified += " LE";
if (LS.value == true)
$not_Qualified += " LS;
// tas
$query = "INSERT INTO tbl_churva(.....,not_qualified) values (......," + $not_Qualified + ");";
// yan na query string... assuming yan na ang column name sa table mo for not qualified is "not_qualified".
// ung mga ...., yan ung mga ibang field na sinisave mo......
Lyt_Grey- Admin
-
Number of posts : 308
Age : 36
Location : La Trinidad, Benguet
Job/hobbies : Ado ngem basit lang
Reputation : 0
Registration date : 2008-12-04
Re: add rows to table dynamically and save 2 d database
tnx..tnx..ung not_qualified i2sang field lng xa..so bale ung value ng checkboxes na pi2liin ng user isa2ve nya sa not_qualified na field..bale pg 3 ung chineck ng user sa 1st row na input nya ang laman ng not_qualified=LA,LE,LS..pg sa second row nman eh LE lng ang chineck ng user ang laman ng not_qualified=LE..
pg i2sang row lng ang finil-apan ng user ng data ok lng ung pgsa2ve nya..kaso pg pinili na ng user ung add row taz ng-input ulit xa ng data ang laman ng field na not_qualified=lahat ng chineck ng user sa row1 and row2..dun ako ngkaproblema..
pg i2sang row lng ang finil-apan ng user ng data ok lng ung pgsa2ve nya..kaso pg pinili na ng user ung add row taz ng-input ulit xa ng data ang laman ng field na not_qualified=lahat ng chineck ng user sa row1 and row2..dun ako ngkaproblema..
mye- Staff Sergeant
-
Number of posts : 113
Age : 36
Location : La Trinidad
Job/hobbies : Computer Instructor
Reputation : 0
Registration date : 2008-11-27
Re: add rows to table dynamically and save 2 d database
ds s my code pala:
if(isset($_GET['button'])){
foreach($_GET['name']as $key=>$val){
if(trim($val)!='')
$name_arr[]=$val;
}
foreach($_GET['age']as $key=>$val){
if(trim($val)!='')
$age_arr[]=$val;
}
foreach($_GET['sex']as $key=>$val){
if(trim($val)!='')
$sex_arr[]=$val;
}
foreach($_GET['position']as $key=>$val){
if(trim($val)!='')
$position_arr[]=$val;
}
foreach($_GET['ffi']as $key=>$val){
if(trim($val)!='')
$ffi_arr[]=$val;
}
foreach($_GET['notQualified'] as &$value) {
$value_arr[]=$value;
}
$notQualified=implode(",", $_GET['notQualified']);
$total_records=count($name_arr);
for($i=0;$i<$total_records;$i++){
$company_name=$_GET['company_name'];
$contact_no=$_GET['contact_no'];
$contact_person=$_GET['contact_person'];
$company_type=$_GET['company_type'];
$name=$name_arr[$i];
$age=$age_arr[$i];
$sex=$sex_arr[$i];
$position=$position_arr[$i];
$ffi=$ffi_arr[$i];
//$notQualified=$notQualified_arr[i];
$query = "INSERT INTO `test`.`add` VALUES('','$company_name','$contact_no','$contact_person','$company_type','$name','$age','$sex','$position','$ffi','$notQualified')";
if(isset($_GET['button'])){
foreach($_GET['name']as $key=>$val){
if(trim($val)!='')
$name_arr[]=$val;
}
foreach($_GET['age']as $key=>$val){
if(trim($val)!='')
$age_arr[]=$val;
}
foreach($_GET['sex']as $key=>$val){
if(trim($val)!='')
$sex_arr[]=$val;
}
foreach($_GET['position']as $key=>$val){
if(trim($val)!='')
$position_arr[]=$val;
}
foreach($_GET['ffi']as $key=>$val){
if(trim($val)!='')
$ffi_arr[]=$val;
}
foreach($_GET['notQualified'] as &$value) {
$value_arr[]=$value;
}
$notQualified=implode(",", $_GET['notQualified']);
$total_records=count($name_arr);
for($i=0;$i<$total_records;$i++){
$company_name=$_GET['company_name'];
$contact_no=$_GET['contact_no'];
$contact_person=$_GET['contact_person'];
$company_type=$_GET['company_type'];
$name=$name_arr[$i];
$age=$age_arr[$i];
$sex=$sex_arr[$i];
$position=$position_arr[$i];
$ffi=$ffi_arr[$i];
//$notQualified=$notQualified_arr[i];
$query = "INSERT INTO `test`.`add` VALUES('','$company_name','$contact_no','$contact_person','$company_type','$name','$age','$sex','$position','$ffi','$notQualified')";
mye- Staff Sergeant
-
Number of posts : 113
Age : 36
Location : La Trinidad
Job/hobbies : Computer Instructor
Reputation : 0
Registration date : 2008-11-27
Re: add rows to table dynamically and save 2 d database
If you use $_GET(), ano ung kinukuha? di ba ung name ng object not wether checked or uncheck xa.
Lyt_Grey- Admin
-
Number of posts : 308
Age : 36
Location : La Trinidad, Benguet
Job/hobbies : Ado ngem basit lang
Reputation : 0
Registration date : 2008-12-04
Re: add rows to table dynamically and save 2 d database
yup knukuha nya ung name ng object taz ung value isa2ve nya sa array..d2 ako sa part ng checkbox nalilito kc..ang output kc ng gnagwa q ngaun pg i2sang row lng ang ia2d ng user ok nman xa..tama ung naisa2ve na laman ng checkbox..kaso pg more than 1 row na ang ia2d ng user dun na ngkakamali ung naisa2ve na laman ng checkbox..bale ang gngwa nya kung ano ung chineck ng user sa row1 at sa lahat ng rows..un ang kinukuha nya taz un ang isa2ve sa lahat ng row..
mye- Staff Sergeant
-
Number of posts : 113
Age : 36
Location : La Trinidad
Job/hobbies : Computer Instructor
Reputation : 0
Registration date : 2008-11-27
Re: add rows to table dynamically and save 2 d database
let's say d user input values sa row1 taz under sa not qualified column chineck nya ung EA at LS na checkbox..taz clinick nya ung add row na button so lumabas ung row2 taz finil-apan nya ulit ung taz under not qualified column chineck nya ung EA lng na checkbox..after that clinick na nya ung submit button..
sa database sa record1 not_qualified=EA,LS
record2 not_qualified=EA
un sana laman ng not_qualified na field kaso ang lumalabas ganito
sa record1 not_qualified=EA,LS,EA
record2 not_qualified=EA,LS,EA
pero pg tig-i2sa lng nman ang ini a2d ng user na record ok pa nman ung implode..tama nman ung naisa2ve sa database..haaay..i hope i made it clear
sa database sa record1 not_qualified=EA,LS
record2 not_qualified=EA
un sana laman ng not_qualified na field kaso ang lumalabas ganito
sa record1 not_qualified=EA,LS,EA
record2 not_qualified=EA,LS,EA
pero pg tig-i2sa lng nman ang ini a2d ng user na record ok pa nman ung implode..tama nman ung naisa2ve sa database..haaay..i hope i made it clear
mye- Staff Sergeant
-
Number of posts : 113
Age : 36
Location : La Trinidad
Job/hobbies : Computer Instructor
Reputation : 0
Registration date : 2008-11-27
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Fri 25 Jan 2013, 12:12 pm by remase
» VB.net+mysql connection string
Wed 11 Apr 2012, 12:51 pm by markjeggar
» pa visit nmn
Tue 03 Jan 2012, 1:37 am by Generym
» How to de-active your account here?
Tue 27 Dec 2011, 1:57 am by Generym
» Team Building
Sat 26 Nov 2011, 5:31 am by kate
» Check attendance: name and batch, currently working at?
Fri 09 Sep 2011, 4:35 am by kuratcha
» I wonder!!!
Fri 01 Jul 2011, 2:08 am by Generym
» happy experience
Sun 01 May 2011, 10:07 pm by i337
» how smart is your smart phone?
Sun 01 May 2011, 9:56 pm by i337